/*
 *  INSANE - Interactive Structural Analysis Environment
 *
 *  Copyright (C) 2003-2006
 *  Universidade Federal de Minas Gerais
 *  Escola de Engenharia
 *  Departamento de Engenharia de Estruturas
 *
 *  Author's email :    insane@dees.ufmg.br
 *  Author's website :  http://www.dees.ufmg.br/insane
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package br.ufmg.dees.insane.persistence;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.Observable;
import java.util.Observer;
import java.util.StringTokenizer;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.SchemaFactory;

import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import br.ufmg.dees.insane.analysisModel.AnalysisModel;
import br.ufmg.dees.insane.analysisModel.Axisymmetric;
import br.ufmg.dees.insane.analysisModel.BFSKirchhoffPlate;
import br.ufmg.dees.insane.analysisModel.Beam;
import br.ufmg.dees.insane.analysisModel.CKZKirchhoffPlate;
import br.ufmg.dees.insane.analysisModel.CowperKirchhoffPlate;
import br.ufmg.dees.insane.analysisModel.EulerSpaceFrame;
import br.ufmg.dees.insane.analysisModel.Grid;
import br.ufmg.dees.insane.analysisModel.HCTKirchhoffPlate;
import br.ufmg.dees.insane.analysisModel.Heterosis;
import br.ufmg.dees.insane.analysisModel.Line_1D;
import br.ufmg.dees.insane.analysisModel.Line_2D;
import br.ufmg.dees.insane.analysisModel.Line_3D;
import br.ufmg.dees.insane.analysisModel.MZCKirchhoffPlate;
import br.ufmg.dees.insane.analysisModel.PlaneFrame;
import br.ufmg.dees.insane.analysisModel.PlaneStrain;
import br.ufmg.dees.insane.analysisModel.PlaneStress;
import br.ufmg.dees.insane.analysisModel.PlaneTruss;
import br.ufmg.dees.insane.analysisModel.PolarPlaneStrain;
import br.ufmg.dees.insane.analysisModel.PolarPlaneStress;
import br.ufmg.dees.insane.analysisModel.ReissnerMindlinPlate;
import br.ufmg.dees.insane.analysisModel.Solid;
import br.ufmg.dees.insane.analysisModel.SpaceFrame;
import br.ufmg.dees.insane.analysisModel.SpaceTruss;
import br.ufmg.dees.insane.analysisModel.TimoSpaceFrame;
import br.ufmg.dees.insane.analysisModel.VeubekeKirchhoffPlate;
import br.ufmg.dees.insane.continuousPointModel.ContinuousPointModel;
import br.ufmg.dees.insane.continuousPointModel.EulerPoint;
import br.ufmg.dees.insane.continuousPointModel.KirchhoffPlatePoint;
import br.ufmg.dees.insane.continuousPointModel.PlaneStressPoint;
import br.ufmg.dees.insane.continuousPointModel.PolarPlaneStressPoint;
import br.ufmg.dees.insane.continuousPointModel.ReissnerMindlinPlatePoint;
import br.ufmg.dees.insane.continuousPointModel.TimoPoint;
import br.ufmg.dees.insane.materialMedia.constitutiveModel.ConstitutiveModel;
import br.ufmg.dees.insane.materialMedia.constitutiveModel.LinearElasticConstModel;
import br.ufmg.dees.insane.materialMedia.constitutiveModel.OnePointConstModel;
import br.ufmg.dees.insane.materialMedia.constitutiveModel.PolarVonMisesConstModel;
import br.ufmg.dees.insane.materialMedia.constitutiveModel.VonMisesConstModel;
import br.ufmg.dees.insane.materialMedia.degeneration.Degeneration;
import br.ufmg.dees.insane.materialMedia.degeneration.PrescribedDegeneration;
import br.ufmg.dees.insane.materialMedia.material.BiLinearPlasticIsotropic;
import br.ufmg.dees.insane.materialMedia.material.ConcreteCarreira;
import br.ufmg.dees.insane.materialMedia.material.ConcreteEC2;
import br.ufmg.dees.insane.materialMedia.material.ConcreteIzzudin2002;
import br.ufmg.dees.insane.materialMedia.material.ConcreteNB1;
import br.ufmg.dees.insane.materialMedia.material.ConcreteSun1993;
import br.ufmg.dees.insane.materialMedia.material.LinearElasticIsotropic;
import br.ufmg.dees.insane.materialMedia.material.LinearElasticOrthotropic;
import br.ufmg.dees.insane.materialMedia.material.LinearPlasticIsotropic;
import br.ufmg.dees.insane.materialMedia.material.LinearPlasticIsotropic2;
import br.ufmg.dees.insane.materialMedia.material.Material;
import br.ufmg.dees.insane.materialMedia.material.PolarLinearElasticIsotropic;
import br.ufmg.dees.insane.materialMedia.material.PolarVonMises;
import br.ufmg.dees.insane.materialMedia.material.VonMises;
import br.ufmg.dees.insane.materialMedia.materialPoint.MaterialPoint;
import br.ufmg.dees.insane.model.femModel.FemModel;
import br.ufmg.dees.insane.model.femModel.Model;
import br.ufmg.dees.insane.model.femModel.element.Bar;
import br.ufmg.dees.insane.model.femModel.element.Element;
import br.ufmg.dees.insane.model.femModel.element.FrameElement;
import br.ufmg.dees.insane.model.femModel.element.Hexahedral;
import br.ufmg.dees.insane.model.femModel.element.ParametricElement;
import br.ufmg.dees.insane.model.femModel.element.Quadrilateral;
import br.ufmg.dees.insane.model.femModel.element.Tetrahedral;
import br.ufmg.dees.insane.model.femModel.element.ThinPlateElement;
import br.ufmg.dees.insane.model.femModel.element.Triangular;
import br.ufmg.dees.insane.model.femModel.element.TriangularThinPlate;
import br.ufmg.dees.insane.model.femModel.elementNode.ElementNode;
import br.ufmg.dees.insane.model.femModel.loads.Loading;
import br.ufmg.dees.insane.model.femModel.node.Node;
import br.ufmg.dees.insane.model.femModel.problemDriver.BFSProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.CKZProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.CowperProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.FrameProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.GeometricallyNonLinearSolidMech;
import br.ufmg.dees.insane.model.femModel.problemDriver.HCTKirchhoffThinPlate;
import br.ufmg.dees.insane.model.femModel.problemDriver.HCTProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.MZCProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.ParametricPhysicallyNonLinearSolidMech;
import br.ufmg.dees.insane.model.femModel.problemDriver.ProblemDriver;
import br.ufmg.dees.insane.model.femModel.problemDriver.RMThinPlateSubstituteShearStrain;
import br.ufmg.dees.insane.model.femModel.problemDriver.ReissnerMindlinThinPlate;
import br.ufmg.dees.insane.model.femModel.problemDriver.VeubekeProblemDriver;
import br.ufmg.dees.insane.shape.BFS;
import br.ufmg.dees.insane.shape.CKZ;
import br.ufmg.dees.insane.shape.Cowper;
import br.ufmg.dees.insane.shape.Cubic1DCart;
import br.ufmg.dees.insane.shape.H20;
import br.ufmg.dees.insane.shape.H8;
import br.ufmg.dees.insane.shape.HCT;
import br.ufmg.dees.insane.shape.HermiteL2;
import br.ufmg.dees.insane.shape.L2;
import br.ufmg.dees.insane.shape.L3;
import br.ufmg.dees.insane.shape.L4;
import br.ufmg.dees.insane.shape.Linear1DCart;
import br.ufmg.dees.insane.shape.LinearCubic1DCart;
import br.ufmg.dees.insane.shape.MZC;
import br.ufmg.dees.insane.shape.Q4;
import br.ufmg.dees.insane.shape.Q8;
import br.ufmg.dees.insane.shape.Q9;
import br.ufmg.dees.insane.shape.Q9H;
import br.ufmg.dees.insane.shape.RMCIQ4;
import br.ufmg.dees.insane.shape.RMCIQ8;
import br.ufmg.dees.insane.shape.RMCIQ9;
import br.ufmg.dees.insane.shape.RMCIT6;
import br.ufmg.dees.insane.shape.Shape;
import br.ufmg.dees.insane.shape.T10;
import br.ufmg.dees.insane.shape.T3;
import br.ufmg.dees.insane.shape.T6;
import br.ufmg.dees.insane.shape.Tetra4;
import br.ufmg.dees.insane.shape.Veubeke;
import br.ufmg.dees.insane.solution.CilindricalArcLengthControl;
import br.ufmg.dees.insane.solution.DisplacementControl;
import br.ufmg.dees.insane.solution.EquilibriumPath;
import br.ufmg.dees.insane.solution.GeneralizedDisplacementControl;
import br.ufmg.dees.insane.solution.InitialOrthogonalArcLengthControl;
import br.ufmg.dees.insane.solution.IteractiveStrategy;
import br.ufmg.dees.insane.solution.LoadControl;
import br.ufmg.dees.insane.solution.OrthogonalResidueControl;
import br.ufmg.dees.insane.solution.OrthogonalResidueStandardNewtonRapson;
import br.ufmg.dees.insane.solution.Solution;
import br.ufmg.dees.insane.solution.StandardNewtonRapson;
import br.ufmg.dees.insane.solution.SteadyState;
import br.ufmg.dees.insane.solution.Step;
import br.ufmg.dees.insane.solution.UpdateOrthogonalArcLengthControl;
import br.ufmg.dees.insane.solution.WorkControl;
import br.ufmg.dees.insane.util.IPoint3d;
import br.ufmg.dees.insane.util.IVector;
import br.ufmg.dees.insane.util.IVolume;
import br.ufmg.dees.insane.util.LoadCase;
import br.ufmg.dees.insane.util.LoadCombination;
import br.ufmg.dees.insane.util.geometricProperties.GeometricProperties;
import br.ufmg.dees.insane.util.numericalIntegration.IntegrationOrder;
import br.ufmg.dees.insane.util.pointValues.BooleanPointValues;
import br.ufmg.dees.insane.util.pointValues.DoublePointValues;
import br.ufmg.dees.insane.util.pointValues.PointValues;
import br.ufmg.dees.insane.util.pointValues.StringPointValues;

/**
 *  A class representing PersistenceAsXML using XML Schema for validation
 *
 *@author     Flavio, Marcos, Roque
 *@created    December 4, 2006
 *@since      21/07/2006
 */
public class PersistenceAsXML_XSD implements Persistence, Observer {

	private final static long serialVersionUID = 1L;

	/**
	 *  The Model of this persistence.
	 */
	protected static Model model;

	private int q = 0;

	/**
	 *  The Solution of this persistence.
	 */
	protected static Solution solution;

	public static String path = "";

	public static String fileName = "model";
	
	/**
	 *  The Object which will be serialized.
	 */
	protected static Object docOutput;

	/**
	 *  Returns the Model of this application.
	 *
	 *@return    The Model of this application.
	 */
	public Model getModel() {
		return (model);
	}

	/**
	 *  Sets the Model of this application.
	 *
	 *@param  m  The new model value
	 */
	public void setModel(Model m) {
		model = m;
	}

	/**
	 *  Returns the Solution of this application.
	 *
	 *@return    The Solution of this application.
	 */
	public Solution getSolution() {
		return (solution);
	}

	/**
	 *  Sets the Solution of this application.
	 *
	 *@param  s  The new solution value
	 */
	public void setSolution(Solution s) {
		solution = s;
	}

	/*
	 *  (non-Javadoc)
	 *  @see br.ufmg.dees.insane.persistence.Persistence#fillModelfromFile(java.lang.String)
	 */
	public void fillInsaneFromFile(String File) {
	    	
	    	//Creating and configuring the SAXParser
	    	SAXParserFactory parserFac = SAXParserFactory.newInstance();
	    	SchemaFactory schemaFac = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 
	    	parserFac.setValidating(true);
	    	parserFac.setNamespaceAware(true);
	    	
		try {
		    	parserFac.setSchema(schemaFac.newSchema(new File("insane.xsd")));
		    	SAXParser parser = parserFac.newSAXParser();
		    	
			// implementing DefaultHandler
		    	parser.parse(File,
				new DefaultHandler() {
					StringBuffer content = new StringBuffer();

					// All the classes which will be instantiated are declared here

					Node node;

					Element elm;

					Shape shp;

					IPoint3d coord;

					IntegrationOrder intOr;

					AnalysisModel anl;

					AnalysisModel globAnl;

					ContinuousPointModel cpm;

					ProblemDriver probDriver;

					Material mat;

					MaterialPoint degenerationPoint;

					Degeneration dg;

					ConstitutiveModel cm;

					IVolume area;

					Step step;

					IteractiveStrategy is;

					IteractiveStrategy[] isVector;

					ArrayList<IteractiveStrategy> isList;

					Loading loading;

					LoadCombination loadComb;

					LoadCase loadCas;

					public void setDocumentLocator(Locator locator) {
					}

					public void characters(char ch[], int start, int length) {
						this.content.append(ch, start, length);
					}

					// ***********************************************************************************************************

					// ALL IFs OF THIS METHOD ARE ACTIVATED WHEN THE PARSER FINDS THE SPECIFIC TAG <...qname...>

					public void startElement(String uri, String localName,
							String qName, Attributes attributes) {

						if ("Insane".equals(qName)) {
						}
						
						// ***TAGS FOR SOLUTION DATA INPUT***
						
						// Read "<Solution ...>"
						else if ("Solution".equals(qName)) {
							if (attributes.getValue("class").equals("SteadyState")) {
								solution = new SteadyState();
							}
							else if (attributes.getValue("class").equals("EquilibriumPath")) {
								solution = new EquilibriumPath();
							}
						}
						
						// Read "<NumMaxSteps ...>"
						else if ("NumMaxSteps".equals(qName)) {
						}
						
						// Read "<ChangeLoadFactor ...>"
						else if ("ChangeLoadFactor".equals(qName)) {
						}
						
						// Read "<ChangeTolerance ...>"
						else if ("ChangeTolerance".equals(qName)) {
						}
						
						// Read "<ChangeNumMaxIterations ...>"
						else if ("ChangeNumMaxIterations".equals(qName)) {
						}
						
						// Read "<Step ...>"
						else if ("Step".equals(qName)) {
							if (attributes.getValue("class").equals("StandardNewtonRapson")) {
								step = new StandardNewtonRapson();
							}
							else if (attributes.getValue("class").equals("OrthogonalResidueStandardNewtonRapson")) {
								step = new OrthogonalResidueStandardNewtonRapson();
							}
						}
						
						// Read "<NumMaxIterations ...>"
						else if ("NumMaxIterations".equals(qName)) {
						}
						
						// Read "<Tolerance ...>"
						else if ("Tolerance".equals(qName)) {
						}
						
						// Read "<ConvergenceType ...>"
						else if ("ConvergenceType".equals(qName)) {
						}
						
						// Read "<DisplacementMax ...>"
						else if ("DisplacementMax".equals(qName)) {
						}
						
						// Read "<IteractiveStrategyList ...>"
						else if ("IteractiveStrategyList".equals(qName)) {
							isList = new ArrayList<IteractiveStrategy>();
						}
						
						// Read "<IteractiveStrategy ...>"
						else if ("IteractiveStrategy".equals(qName)) {

							if (attributes.getValue("class").equals("CilindricalArcLengthControl")) {
								is = new CilindricalArcLengthControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("InitialOrthogonalArcLengthControl")) {
								is = new InitialOrthogonalArcLengthControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("UpdateOrthogonalArcLengthControl")) {
								is = new UpdateOrthogonalArcLengthControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("DisplacementControl")) {
								is = new DisplacementControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("GeneralizedDisplacementControl")) {
								is = new GeneralizedDisplacementControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("LoadControl")) {
								is = new LoadControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("OrthogonalResidueControl")) {
								is = new OrthogonalResidueControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
							else if (attributes.getValue("class").equals("WorkControl")) {
								is = new WorkControl();
								is.setLoadFactor(Double.parseDouble(attributes.getValue("LoadFactor")));
								isList.add(is);
							}
						}
						
						// Read "<LoadFactor ...>"
						else if ("LoadFactor".equals(qName)) {
						}
						
						// Read "<NodeControl ...>"
						else if ("NodeControl".equals(qName)) {
						}
						
						// Read "<DirectionControl ...>"
						else if ("DirectionControl".equals(qName)) {
						}
						
						// ***TAGS FOR MODEL DATA INPUT***
						
						// Read "<Model ...>"
						else if ("Model".equals(qName)) {
							if (attributes.getValue("class").equals("FemModel")) {
								model = new FemModel();
							}
						}
						
						// Read "<ProblemDriver ...>"
						else if ("ProblemDriver".equals(qName)) {
						}
						
						// Read "<GlobalAnalysisModel>"
						else if ("GlobalAnalysisModel".equals(qName)) {
						}
						
						// ***TAGS FOR NODES DATA INPUT***
						
						// Read "<NodeList ...>"
						else if ("NodeList".equals(qName)) {
						}
						
						// Read "<Node ...>"
						else if ("Node".equals(qName)) {
							node = new Node();
							node.setLabel(attributes.getValue("label"));
						}
						
						// Read "<Coord ...>"
						else if ("Coord".equals(qName)) {
							coord = new IPoint3d();
						}
						
						// Read "<DOFLabels ...>"
						else if ("DOFLabels".equals(qName)) {
						}
						
						// Read "<NodeValues ...>"
						else if ("NodeValues".equals(qName)) {
						}
						
						// Read "<Restraints ...>"
						else if ("Restraints".equals(qName)) {
						}
						
						// Read "<PreDisplacements ...>"
						else if ("PreDisplacements".equals(qName)) {
						}
						
						// Read "<Coeficients ...>"
						else if ("Coeficients".equals(qName)) {
						}
						
						// ***TAGS FOR MATERIALS DATA INPUT***
						
						// Read "<MaterialList ...>"
						else if ("MaterialList".equals(qName)) {
						}
						
						// Read "<Material ...>"
						else if ("Material".equals(qName)) {
							if (attributes.getValue("class").equals("LinearElasticIsotropic")) {
								mat = new LinearElasticIsotropic();
							}
							else if (attributes.getValue("class").equals("PolarLinearElasticIsotropic")) {
								mat = new PolarLinearElasticIsotropic();
							}
							else if (attributes.getValue("class").equals("LinearElasticOrthotropic")) {
								mat = new LinearElasticOrthotropic();
							}
							else if (attributes.getValue("class").equals("LinearPlasticIsotropic")) {
								mat = new LinearPlasticIsotropic();
							}
							else if (attributes.getValue("class").equals("BiLinearPlasticIsotropic")) {
								mat = new BiLinearPlasticIsotropic();
							}
							else if (attributes.getValue("class").equals("LinearPlasticIsotropic2")) {
								mat = new LinearPlasticIsotropic2();
							}
							else if (attributes.getValue("class").equals("ConcreteNB1")) {
								mat = new ConcreteNB1();
							}
							else if (attributes.getValue("class").equals("ConcreteEC2")) {
								mat = new ConcreteEC2();
							}
							else if (attributes.getValue("class").equals("ConcreteCarreira")) {
								mat = new ConcreteCarreira();
							}
							else if (attributes.getValue("class").equals("ConcreteIzzudin2002")) {
								mat = new ConcreteIzzudin2002();
							}
							else if (attributes.getValue("class").equals("ConcreteSun1993")) {
								mat = new ConcreteSun1993();
							}
							else if (attributes.getValue("class").equals("VonMises")) {
								mat = new VonMises();
							}
							else if (attributes.getValue("class").equals("PolarVonMises")) {
								mat = new PolarVonMises();
							}
							mat.setLabel(attributes.getValue("label"));
						}
						
						// Read "<Elasticity ...>"
						else if ("Elasticity".equals(qName)) {
						}
						
						// Read "<Elasticity2 ...>"
						else if ("Elasticity2".equals(qName)) {
						}
						
						// Read "<Elasticity11 ...>"
						else if ("Elasticity11".equals(qName)) {
						}
						
						// Read "<Elasticity22 ...>"
						else if ("Elasticity22".equals(qName)) {
						}
						
						// Read "<Elasticity33 ...>"
						else if ("Elasticity33".equals(qName)) {
						}
						
						// Read "<Poisson ...>"
						else if ("Poisson".equals(qName)) {
						}
						
						// Read "<Poisson12 ...>"
						else if ("Poisson12".equals(qName)) {
						}
						
						// Read "<Poisson13 ...>"
						else if ("Poisson13".equals(qName)) {
						}
						
						// Read "<Poisson23 ...>"
						else if ("Poisson23".equals(qName)) {
						}
						
						// Read "<ThermalCoeff ...>"
						else if ("ThermalCoeff".equals(qName)) {
						}
						
						// Read "<Ec0>"
						else if ("Ec0".equals(qName)) {
						}
						
						// Read "<Ecm>"
						else if ("Ecm".equals(qName)) {
						}
						
						// Read "<Fcm>"
						else if ("Fcm".equals(qName)) {
						}
						
						// Read "<Dc1>"
						else if ("Dc1".equals(qName)) {
						}
						
						// Read "<Dcu>"
						else if ("Dcu".equals(qName)) {
						}
						
						// Read "<ShearModulus ...>"
						else if ("ShearModulus".equals(qName)) {
						}
						
						// Read "<Yielding ...>"
						else if ("Yielding".equals(qName)) {
						}
						
						// Read "<HardeningModulus ...>"
						else if ("HardeningModulus".equals(qName)) {
						}
						
						// Read "<Fck ...>"
						else if ("Fck".equals(qName)) {
						}
						
						// Read "<Fc ...>"
						else if ("Fc".equals(qName)) {
						}
						
						// Read "<Alpha ...>"
						else if ("Alpha".equals(qName)) {
						}
						
						// Read "<Eta ...>"
						else if ("Eta".equals(qName)) {
						}
						
						// Read "<LengthBending ...>"
						else if ("LengthBending".equals(qName)) {
						}
						
						// Read "<LengthTorsion ...>"
						else if ("LengthTorsion".equals(qName)) {
						}
						
						// ***TAGS FOR CROSSSECTIONS DATA INPUT***
						
						// Read "<DegenerationList ...>"
						else if ("DegenerationList".equals(qName)) {
						}
						
						// Read "<Degeneration ...>"
						else if ("Degeneration".equals(qName)) {
							if (attributes.getValue("class").equals("PrescribedDegeneration")) {
								PrescribedDegeneration pdg = new PrescribedDegeneration();
								dg = pdg;
							} else {
								dg = new Degeneration();
							}
							dg.setOriginalLabel(attributes.getValue("label"));
							dg.setLabel(attributes.getValue("label"));
						}
						
						// Read "<DegenerationPoint ...>"
						else if ("DegenerationPoint".equals(qName)) {
							degenerationPoint = new MaterialPoint();
							degenerationPoint.setLabel("MP-" + attributes.getValue("label"));
							StringTokenizer stk = new StringTokenizer(attributes.getValue("SectionCoord"), " ");
							degenerationPoint.setPoint(Double.parseDouble(stk.nextToken()), Double.parseDouble(stk.nextToken()));
						}
						
						// Read "<PointConstitutiveModel ...>"
						else if ("PointConstitutiveModel".equals(qName)) {
						}
						
						// Read "<PointAnalysisModel ...>"
						else if ("PointAnalysisModel".equals(qName)) {
						}
						
						// Read "<PointMaterial ...>"
						else if ("PointMaterial".equals(qName)) {
						}
						
						// Read "<Area ...>"
						else if ("Area".equals(qName)) {
						}
						
						// Read "<Ix ...>"
						else if ("Ix".equals(qName)) {
						}
						
						// Read "<Iy ...>"
						else if ("Iy".equals(qName)) {
						}
						
						// Read "<Iz ...>"
						else if ("Iz".equals(qName)) {
						}
						
						// Read "<Height ...>"
						else if ("Height".equals(qName)) {
						}

						//Read "<Thickness ...>"
						else if ("Thickness".equals(qName)) {
						}
						
						//Read "<CSMaterial ...>"
						else if ("CSMaterial".equals(qName)) {
						}
						
						// Read "<FormFactorY ...>"
						else if ("FormFactorY".equals(qName)) {
						}
						
						// Read "<FormFactorZ ...>"
						else if ("FormFactorZ".equals(qName)) {
						}
						
						// ***TAGS FOR ELEMENTS DATA INPUT***
						
						// Read "<ElementList ...>"
						else if ("ElementList".equals(qName)) {
						}
						
						// Read "<Element ...>"
						else if ("Element".equals(qName)) {
							if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.Q4")
									 || attributes.getValue("class").equals("ParametricElement.Quadrilateral.AxiQ4")
									 || attributes.getValue("class").equals("Q4")) {
								if (model.getShape("Q4") == null) {
									shp = new Q4();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("Q4"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.RMCIQ4")
									 || attributes.getValue("class").equals("RMCIQ4")) {
								if (model.getShape("RMCIQ4") == null) {
									shp = new RMCIQ4();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("RMCIQ4"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.Q8")
									 || attributes.getValue("class").equals("ParametricElement.Quadrilateral.AxiQ8")
									 || attributes.getValue("class").equals("Q8")) {
								if (model.getShape("Q8") == null) {
									shp = new Q8();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("Q8"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.RMCIQ8")
									 || attributes.getValue("class").equals("RMCIQ8")) {
								if (model.getShape("RMCIQ8") == null) {
									shp = new RMCIQ8();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("RMCIQ8"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.Q9")
									 || attributes.getValue("class").equals("ParametricElement.Quadrilateral.AxiQ9")
									 || attributes.getValue("class").equals("Q9")) {
								if (model.getShape("Q9") == null) {
									shp = new Q9();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("Q9"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.RMCIQ9")
									 || attributes.getValue("class").equals("RMCIQ9")) {
								if (model.getShape("RMCIQ9") == null) {
									shp = new RMCIQ9();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("RMCIQ9"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.Q9H")
									 || attributes.getValue("class").equals("Q9H")) {
								if (model.getShape("Q9H") == null) {
									shp = new Q9H();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("Q9H"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.MZC")
									 || attributes.getValue("class").equals("MZC")) {
								if (model.getShape("MZC") == null) {
									shp = new MZC();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("MZC"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Quadrilateral.BFS")
									 || attributes.getValue("class").equals("BFS")) {
								if (model.getShape("BFS") == null) {
									shp = new BFS();
									model.add(shp);
								}
								elm = new Quadrilateral();
								elm.setShape(model.getShape("BFS"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Triangular.T3")
									 || attributes.getValue("class").equals("T3")) {
								if (model.getShape("T3") == null) {
									shp = new T3();
									model.add(shp);
								}
								elm = new Triangular();
								elm.setShape(model.getShape("T3"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Triangular.T6")
									 || attributes.getValue("class").equals("T6")) {
								if (model.getShape("T6") == null) {
									shp = new T6();
									model.add(shp);
								}
								elm = new Triangular();
								elm.setShape(model.getShape("T6"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Triangular.RMCIT6")
									 || attributes.getValue("class").equals("RMCIT6")) {
								if (model.getShape("RMCIT6") == null) {
									shp = new RMCIT6();
									model.add(shp);
								}
								elm = new Triangular();
								elm.setShape(model.getShape("RMCIT6"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Triangular.T10")
									 || attributes.getValue("class").equals("T10")) {
								if (model.getShape("T10") == null) {
									shp = new T10();
									model.add(shp);
								}
								elm = new Triangular();
								elm.setShape(model.getShape("T10"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Triangular.CKZ")
									 || attributes.getValue("class").equals("CKZ")) {
								if (model.getShape("CKZ") == null) {
									shp = new CKZ();
									model.add(shp);
								}
								elm = new Triangular();
								elm.setShape(model.getShape("CKZ"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Triangular.HCT")
									 || attributes.getValue("class").equals("HCT")) {
								if (model.getShape("HCT") == null) {
									shp = new HCT();
									model.add(shp);
								}
								elm = new Triangular();
								elm.setShape(model.getShape("HCT"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Hexahedral.H8")
									 || attributes.getValue("class").equals("H8")) {
								if (model.getShape("H8") == null) {
									shp = new H8();
									model.add(shp);
								}
								elm = new Hexahedral();
								elm.setShape(model.getShape("H8"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Hexahedral.H20")
									 || attributes.getValue("class").equals("H20")) {
								if (model.getShape("H20") == null) {
									shp = new H20();
									model.add(shp);
								}
								elm = new Hexahedral();
								elm.setShape(model.getShape("H20"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Tetrahedral.Tetra4")
									 || attributes.getValue("class").equals("Tetra4")) {
								if (model.getShape("Tetra4") == null) {
									shp = new Tetra4();
									model.add(shp);
								}
								elm = new Tetrahedral();
								elm.setShape(model.getShape("Tetra4"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Bar.L2")
									 || attributes.getValue("class").equals("L2")) {
								if (model.getShape("L2") == null) {
									shp = new L2();
									model.add(shp);
								}
								elm = new Bar();
								elm.setShape(model.getShape("L2"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Bar.HermiteL2")
									 || attributes.getValue("class").equals("HermiteL2")) {
								if (model.getShape("HermiteL2") == null) {
									shp = new HermiteL2();
									model.add(shp);
								}
								elm = new Bar();
								elm.setShape(model.getShape("HermiteL2"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Bar.L3")
									 || attributes.getValue("class").equals("L3")) {
								if (model.getShape("L3") == null) {
									shp = new L3();
									model.add(shp);
								}
								elm = new Bar();
								elm.setShape(model.getShape("L3"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ParametricElement.Bar.L4")
									 || attributes.getValue("class").equals("L4")) {
								if (model.getShape("L4") == null) {
									shp = new L4();
									model.add(shp);
								}
								elm = new Bar();
								elm.setShape(model.getShape("L4"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ThinPlateElement.MZC")
									 || attributes.getValue("class").equals("MZC")) {
								if (model.getShape("MZC") == null) {
									shp = new MZC();
									model.add(shp);
								}
								elm = new ThinPlateElement();
								elm.setShape(model.getShape("MZC"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ThinPlateElement.BFS")
									 || attributes.getValue("class").equals("BFS")) {
								if (model.getShape("BFS") == null) {
									shp = new BFS();
									model.add(shp);
								}
								elm = new ThinPlateElement();
								elm.setShape(model.getShape("BFS"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ThinPlateElement.CKZ")
									 || attributes.getValue("class").equals("CKZ")) {
								if (model.getShape("CKZ") == null) {
									shp = new CKZ();
									model.add(shp);
								}
								elm = new TriangularThinPlate();
								elm.setShape(model.getShape("CKZ"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ThinPlateElement.Cowper")
									 || attributes.getValue("class").equals("Cowper")) {
								if (model.getShape("Cowper") == null) {
									shp = new Cowper();
									model.add(shp);
								}
								elm = new TriangularThinPlate();
								elm.setShape(model.getShape("Cowper"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ThinPlateElement.HCT")
									 || attributes.getValue("class").equals("HCT")) {
								if (model.getShape("HCT") == null) {
									shp = new HCT();
									model.add(shp);
								}
								elm = new TriangularThinPlate();
								elm.setShape(model.getShape("HCT"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("ThinPlateElement.Veubeke")
									 || attributes.getValue("class").equals("Veubeke")) {
								if (model.getShape("Veubeke") == null) {
									shp = new Veubeke();
									model.add(shp);
								}
								elm = new ThinPlateElement();
								elm.setShape(model.getShape("Veubeke"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("FrameElement.Linear1DCart")) {
								if (model.getShape("Linear1DCart") == null) {
									shp = new Linear1DCart();
									model.add(shp);
								}
								elm = new FrameElement();
								elm.setShape(model.getShape("Linear1DCart"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("FrameElement.Cubic1DCart")) {
								if (model.getShape("Cubic1DCart") == null) {
									shp = new Cubic1DCart();
									model.add(shp);
								}
								elm = new FrameElement();
								elm.setShape(model.getShape("Cubic1DCart"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							else if (attributes.getValue("class").equals("FrameElement.LinearCubic1DCart")) {
								if (model.getShape("LinearCubic1DCart") == null) {
									shp = new LinearCubic1DCart();
									model.add(shp);
								}
								elm = new FrameElement();
								elm.setShape(model.getShape("LinearCubic1DCart"));
								elm.setMyProblemDriver(model.getProblemDriver());
							}
							elm.setLabel(attributes.getValue("label"));
						}
						
						// Read "<Incidence ...>"
						else if ("Incidence".equals(qName)) {
						}
						
						// Read "<IntegrationOrder>"
						else if ("IntegrationOrder".equals(qName)) {
						}
						
						// Read "<ConstitutiveModel>"
						else if ("ConstitutiveModel".equals(qName)) {
						}
						
						// Read "<ElmDegenerations>"
						else if ("ElmDegenerations".equals(qName)) {
						}
						
						// Read "<AnalysisModel ...>"
						else if ("AnalysisModel".equals(qName)) {
						}
						
						//***TAGS FOR LOADING DATA INPUT***
						
						// Read "<LoadingList>"
						else if ("LoadingList".equals(qName)) {
						}
						
						// Read "<Loading>"
						else if ("Loading".equals(qName)) {
							loading = new Loading();
							loading.setLabel(attributes.getValue("label"));
						}
						
						// Read "<NodeLoad>"
						else if ("NodeLoad".equals(qName)) {
							node = model.getNode(attributes.getValue("node"));
						}
						
						// ***TAGS FOR LOADCOMBINATIONS DATA INPUT***
						
						// Read "<LoadCombinations ...>"
						else if ("LoadCombinations".equals(qName)) {
						}
						
						// Read "<LoadCombination ...>"
						else if ("LoadCombination".equals(qName)) {
							loadComb = new LoadCombination();
							loadComb.setLabel(attributes.getValue("label"));
						}
						
						// Read "<LoadCase ...>"
						else if ("LoadCase".equals(qName)) {
							loadCas = new LoadCase();
							loadCas.setLabel(attributes.getValue("loading"));
							loadCas.setIsIncremental(Boolean.parseBoolean(attributes.getValue("inc")));
							loadCas.setFactor(Double.parseDouble(attributes.getValue("factor")));
						}
					}
					// END OF START ELEMENT*********************************************

					// ALL IFs OF THIS METHOD ARE ACTIVATED WHEN THE PARSER FIND THE
					// SPECIFIC END TAG </qname...>
					public void endElement(String uri, String localName,
							String qName) {
					    	
						if ("Insane".equals(qName)) {
						}
						
						// ***TAGS FOR SOLUTION DATA INPUT***
						
						// Read "</Solution>"
						else if ("Solution".equals(qName)) {
						}
						
						// Read "</NumMaxSteps>"
						else if ("NumMaxSteps".equals(qName)) {
							((EquilibriumPath) solution).setNumMaxSteps(Integer.parseInt(content.toString()));
						}
						
						// Read "</FinalLoadFactor>"
						else if ("FinalLoadFactor".equals(qName)) {
							((EquilibriumPath) solution).getStep().setLoadFactorTotal(Double.parseDouble(content.toString()));
						}
						
						// Read "</ChangeLoadFactor>"
						else if ("ChangeLoadFactor".equals(qName)) {
							((EquilibriumPath) solution).setchangeLoadFactor(Double.parseDouble(content.toString()));
						}
						
						// Read "</ChangeTolerance>"
						else if ("ChangeTolerance".equals(qName)) {
							((EquilibriumPath) solution).setchangeTolerance(Double.parseDouble(content.toString()));
						}
						
						// Read "</ChangeNumMaxIterations>"
						else if ("ChangeNumMaxIterations".equals(qName)) {
							((EquilibriumPath) solution).setchangeNumMaxIterations(Integer.parseInt(content.toString()));
						}
						
						// Read "</Step>"
						else if ("Step".equals(qName)) {
							((EquilibriumPath) solution).setStep(step);
						}
						
						// Read "</NumMaxIterations>"
						else if ("NumMaxIterations".equals(qName)) {
							step.setNumMaxIterations(Integer.parseInt(content.toString()));
						}
						
						// Read "</Tolerance>"
						else if ("Tolerance".equals(qName)) {
							step.setTolerance(Double.parseDouble(content.toString()));
						}
						
						// Read "</ConvergenceType>"
						else if ("ConvergenceType".equals(qName)) {
							step.setConvType(Byte.parseByte(content.toString()));
						}
						
						// Read "</DisplacementMax>"
						else if ("DisplacementMax".equals(qName)) {
							((OrthogonalResidueStandardNewtonRapson) step).setDXmax(Double.parseDouble(content.toString()));
						}
						
						// Read "</IteractiveStrategyList>"
						else if ("IteractiveStrategyList".equals(qName)) {
							isVector = new IteractiveStrategy[isList.size()];
							for (int i = 0; i < isList.size(); i++) {
								isVector[i] = (IteractiveStrategy) isList.get(i);
							}
							((EquilibriumPath) solution).setIteractiveStrategy(isVector);
						}
						
						// Read "</IteractiveStrategy>"
						else if ("IteractiveStrategy".equals(qName)) {
						}
						
						// Read "</NodeControl>"
						else if ("NodeControl".equals(qName)) {
							((DisplacementControl) is).setNodeControl(content.toString());
						}
						
						// Read "</DirectionControl>"
						else if ("DirectionControl".equals(qName)) {
							((DisplacementControl) is).setDirectionControl(Integer.parseInt(content.toString()));
						}
						
						// ***TAGS FOR MODEL DATA INPUT***
						
						// Read "</Model>"
						else if ("Model".equals(qName)) {
						}
						
						// Read "</ProblemDriver>"
						else if ("ProblemDriver".equals(qName)) {
							if (content.toString().equals("ParametricPhysicallyNonLinearSolidMech")) {
								probDriver = new ParametricPhysicallyNonLinearSolidMech();
							}
							else if (content.toString().equals("ReissnerMindlinThinPlate")) {
								probDriver = new ReissnerMindlinThinPlate();
							}
							else if (content.toString().equals("RMThinPlateSubstituteShearStrain")) {
								probDriver = new RMThinPlateSubstituteShearStrain();
							}
							else if (content.toString().equals("MZCProblemDriver")) {
								probDriver = new MZCProblemDriver();
							}
							else if (content.toString().equals("BFSProblemDriver")) {
								probDriver = new BFSProblemDriver();
							}
							else if (content.toString().equals("CKZProblemDriver")) {
								probDriver = new CKZProblemDriver();
							}
							else if (content.toString().equals("CowperProblemDriver")) {
								probDriver = new CowperProblemDriver();
							}
							else if (content.toString().equals("HCTKirchhoffThinPlate")) {
								probDriver = new HCTKirchhoffThinPlate();
							}
							else if (content.toString().equals("HCTProblemDriver")) {
								probDriver = new HCTProblemDriver();
							}
							else if (content.toString().equals("VeubekeProblemDriver")) {
								probDriver = new VeubekeProblemDriver();
							}
							else if (content.toString().equals("FrameProblemDriver")) {
								probDriver = new FrameProblemDriver();
							}
							else if (content.toString().equals("GeometricallyNonLinearSolidMech")) {
								probDriver = new GeometricallyNonLinearSolidMech();
							}
							model.setProblemDriver(probDriver);
						}
						
						// Read "</GlobalAnalysisModel>"
						else if ("GlobalAnalysisModel".equals(qName)) {
							if (content.toString().equals("ReissnerMindlinPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new ReissnerMindlinPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Axisymmetric")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Axisymmetric();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Line_1D")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Line_1D();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Line_2D")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Line_2D();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Line_3D")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Line_3D();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Heterosis")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Heterosis();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("MZCKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new MZCKirchhoffPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("BFSKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new BFSKirchhoffPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("CKZKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new CKZKirchhoffPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("CowperKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new CowperKirchhoffPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("HCTKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new HCTKirchhoffPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("VeubekeKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new VeubekeKirchhoffPlate();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("TimoshenkoSpaceFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new TimoSpaceFrame();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("EulerSpaceFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new EulerSpaceFrame();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("PolarPlaneStrain")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new PolarPlaneStrain();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("PolarPlaneStress")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new PolarPlaneStress();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("PlaneStrain")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new PlaneStrain();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("PlaneStress")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new PlaneStress();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("PlaneTruss")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new PlaneTruss();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Beam")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Beam();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Grid")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Grid();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("PlaneFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new PlaneFrame();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("SpaceTruss")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new SpaceTruss();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("SpaceFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new SpaceFrame();
									model.add(globAnl);
								}
							}
							else if (content.toString().equals("Solid")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									globAnl = new Solid();
									model.add(globAnl);
								}
							}
							globAnl = model.getAnalysisModel(content.toString());
							model.setGlobalAnalysisModel(globAnl);
						}
						
						// ***TAGS FOR NODES DATA INPUT***
												
						// Read "</NodeList>"
						else if ("NodeList".equals(qName)) {
						}
						
						// Read "</Node>"
						else if ("Node".equals(qName)) {
							model.add(node);
						}
						
						// Read "</Coord>"
						else if ("Coord".equals(qName)) {
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							coord.x = Double.parseDouble(stk.nextToken());
							coord.y = Double.parseDouble(stk.nextToken());
							if (stk.hasMoreTokens()) {
								coord.z = Double.parseDouble(stk.nextToken());
							}
							node.setPoint(coord);
						}
						
						// Read "</DOFLabels>"
						else if ("DOFLabels".equals(qName)) {

							StringPointValues spv = new StringPointValues();
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							int cont = stk.countTokens();
							for (int i = 0; i < cont; i++) {
								String s = stk.nextToken();
								spv.addPointValue(s);
							}
							node.setNodeValues(node.DOF_LABELS, spv);

						}
						
						// Read "</Displacements>"
						else if ("Displacements".equals(qName)) {
							DoublePointValues dpv = new DoublePointValues();
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							int cont = stk.countTokens();
							for (int i = 0; i < cont; i++) {
								String s = stk.nextToken();
								dpv.addPointValue(s);
							}
							node.setNodeValues(Node.STATE_VARIABLE, dpv);
						}
						
						// Read "</NodeValues>"
						else if ("NodeValues".equals(qName)) {
						}
						
						// Read "</Restraints>"
						else if ("Restraints".equals(qName)) {
							BooleanPointValues bpv = new BooleanPointValues();
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							int cont = stk.countTokens();
							for (int i = 0; i < cont; i++) {
								if (stk.nextToken().toLowerCase().equals("true")) {
									bpv.addPointValue(true);
								} else {
									bpv.addPointValue(false);
								}
							}
							node.setNodeValues(node.RESTRAINTS, bpv);
						}
						
						// Read "</PreDisplacements>"
						else if ("PreDisplacements".equals(qName)) {
							DoublePointValues dpv = new DoublePointValues();
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							int cont = stk.countTokens();
							for (int i = 0; i < cont; i++) {
								dpv.setPointValueAsDouble(i, Double.parseDouble(stk.nextToken()));
							}
							node.setNodeValues(Node.PRE_STATE_VARIABLE, dpv);
						}
						
						// Read "</Coeficients>"
						else if ("Coeficients".equals(qName)) {
							DoublePointValues dpv = new DoublePointValues();
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							int cont = stk.countTokens();
							for (int i = 0; i < cont; i++) {
								dpv.setPointValueAsDouble(i, Double.parseDouble(stk.nextToken()));
							}
							node.setNodeValues(node.COEFICIENTS_C, dpv);
						}
						
						// ***TAGS FOR MATERIALS DATA INPUT***
						
						// Read "</MaterialList>"
						else if ("MaterialList".equals(qName)) {
						}
						
						// Read "</Material>"
						else if ("Material".equals(qName)) {
							model.add(mat);
						}
						
						// Read "</Elasticity>"
						else if ("Elasticity".equals(qName)) {
							mat.setMaterialValues("ELASTICITY", Double.parseDouble(content.toString()));
						}
						
						// Read "</Elasticity2>"
						else if ("Elasticity2".equals(qName)) {
							mat.setMaterialValues("ELASTICITY2", Double.parseDouble(content.toString()));
						}
						
						// Read "</Elasticity11>"
						else if ("Elasticity11".equals(qName)) {
							mat.setMaterialValues("ELASTICITY11", Double.parseDouble(content.toString()));
						}
						
						// Read "</Elasticity22>"
						else if ("Elasticity22".equals(qName)) {
							mat.setMaterialValues("ELASTICITY22", Double.parseDouble(content.toString()));
						}
						
						// Read "</Elasticity33>"
						else if ("Elasticity33".equals(qName)) {
							mat.setMaterialValues("ELASTICITY33", Double.parseDouble(content.toString()));
						}
						
						// Read "</Poisson>"
						else if ("Poisson".equals(qName)) {
							mat.setMaterialValues("POISSON", Double.parseDouble(content.toString()));
						}
						
						// Read "</Poisson12>"
						else if ("Poisson12".equals(qName)) {
							mat.setMaterialValues("POISSON12", Double.parseDouble(content.toString()));
						}
						
						// Read "</Poisson13>"
						else if ("Poisson13".equals(qName)) {
							mat.setMaterialValues("POISSON13", Double.parseDouble(content.toString()));
						}
						
						// Read "</Poisson23>"
						else if ("Poisson23".equals(qName)) {
							mat.setMaterialValues("POISSON23", Double.parseDouble(content.toString()));
						}
						
						// Read "</ThermalCoeff>"
						else if ("ThermalCoeff".equals(qName)) {
							mat.setMaterialValues("THERMAL_COEFF", Double.parseDouble(content.toString()));
						}
						
						// Read "</Ec0>"
						else if ("Ec0".equals(qName)) {
							mat.setMaterialValues("Ec0", Double.parseDouble(content.toString()));
						}
						
						// Read "</Ecm>"
						else if ("Ecm".equals(qName)) {
							mat.setMaterialValues("Ecm", Double.parseDouble(content.toString()));
						}
						
						// Read "</Fcm>"
						else if ("Fcm".equals(qName)) {
							mat.setMaterialValues("Fcm", Double.parseDouble(content.toString()));
						}
						
						// Read "</Dc1>"
						else if ("Dc1".equals(qName)) {
							mat.setMaterialValues("Dc1", Double.parseDouble(content.toString()));
						}
						
						// Read "</Dcu>"
						else if ("Dcu".equals(qName)) {
							mat.setMaterialValues("Dcu", Double.parseDouble(content.toString()));
						}
						
						// Read "</ShearModulus>"
						else if ("ShearModulus".equals(qName)) {
							mat.setMaterialValues("SHEAR_MODULUS", Double.parseDouble(content.toString()));
						}
						
						// Read "</Yielding>"
						else if ("Yielding".equals(qName)) {
							mat.setMaterialValues("YIELDING", Double.parseDouble(content.toString()));
						}
						
						// Read "</HardeningModulus>"
						else if ("HardeningModulus".equals(qName)) {
							mat.setMaterialValues("HARDENING_MODULUS", Double.parseDouble(content.toString()));
						}
						
						// Read "</Fck>"
						else if ("Fck".equals(qName)) {
							mat.setMaterialValues("Fck", Double.parseDouble(content.toString()));
						}
						
						// Read "</Fc>"
						else if ("Fc".equals(qName)) {
							mat.setMaterialValues("Fc", Double.parseDouble(content.toString()));
						}
						
						// Read "</Ft>"
						else if ("Ft".equals(qName)) {
							mat.setMaterialValues("Ft", Double.parseDouble(content.toString()));
						}
						
						// Read "</ec>"
						else if ("ec".equals(qName)) {
							mat.setMaterialValues("ec", Double.parseDouble(content.toString()));
						}
						
						// Read "</et>"
						else if ("et".equals(qName)) {
							mat.setMaterialValues("et", Double.parseDouble(content.toString()));
						}
						
						// Read "</E0>"
						else if ("E0".equals(qName)) {
							mat.setMaterialValues("E0", Double.parseDouble(content.toString()));
						}
						
						// Read "</Alpha>"
						else if ("Alpha".equals(qName)) {
							mat.setMaterialValues("ALPHA", Double.parseDouble(content.toString()));
						}
						
						// Read "</Eta>"
						else if ("Eta".equals(qName)) {
							mat.setMaterialValues("ETA", Double.parseDouble(content.toString()));
						}
						
						// Read "</LengthBending>"
						else if ("LengthBending".equals(qName)) {
							mat.setMaterialValues("LENGTH_BENDING", Double.parseDouble(content.toString()));
						}
						
						// Read "</LengthTorsion>"
						else if ("LengthTorsion".equals(qName)) {
							mat.setMaterialValues("LENGTH_TORSION", Double.parseDouble(content.toString()));
						}
						
						// ***TAGS FOR DEGENERATIONS DATA INPUT***
						
						// Read "</DegenerationList>"
						else if ("DegenerationList".equals(qName)) {
						}
						
						// Read "</Degeneration>"
						else if ("Degeneration".equals(qName)) {
							model.add(dg);
						}
												
						// Read "</DegenerationPoint>"
						else if ("DegenerationPoint".equals(qName)) {
							dg.add(degenerationPoint);
						}
						
						// Read "</PointConstitutiveModel>"
						else if ("PointConstitutiveModel".equals(qName)) {
							if (content.toString().equals("LinearElasticConstModel")) {
								if (model.getConstitutiveModel(content.toString()) == null) {
									cm = new LinearElasticConstModel();
									model.add(cm);
								}
							}
							else if (content.toString().equals("OnePointConstModel")) {
								if (model.getConstitutiveModel(content.toString()) == null) {
									cm = new OnePointConstModel();
									model.add(cm);
								}
							}
							else if (content.toString().equals("VonMisesConstModel")) {
								if (model.getConstitutiveModel(content.toString()) == null) {
									cm = new VonMisesConstModel();
									model.add(cm);
								}
							}
							degenerationPoint.setCm(model.getConstitutiveModel(content.toString()));
						}
						
						// Read "</PointAnalysisModel>"
						else if ("PointAnalysisModel".equals(qName)) {
							if (content.toString().equals("TimoshenkoPoint")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									cpm = new TimoPoint();
									model.add(cpm);
								}
							}
							else if (content.toString().equals("EulerPoint")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									cpm = new EulerPoint();
									model.add(cpm);
								}
							}
							else if (content.toString().equals("PlaneStressPoint")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									cpm = new PlaneStressPoint();
									model.add(cpm);
								}
							}
//						else if (content.toString().equals("PlaneStrainPoint")) {
//							if (model.getAnalysisModel(content.toString()) == null) {
//								cpm = new PlaneStrainPoint();
//								model.add(cpm);
//							}
//						}
							else if (content.toString().equals("PolarPlaneStressPoint")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									cpm = new PolarPlaneStressPoint();
									model.add(cpm);
								}
							}
							else if (content.toString().equals("ReissnerMindlinPlatePoint")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									cpm = new ReissnerMindlinPlatePoint();
									model.add(cpm);
								}
							}
							else if (content.toString().equals("KirchhoffPlatePoint")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									cpm = new KirchhoffPlatePoint();
									model.add(cpm);
								}
							}
							degenerationPoint.setContinuousPointModel((ContinuousPointModel) model.getContinuousPointModel(content.toString()));
						}
						
						// Read "</PointMaterial>"
						else if ("PointMaterial".equals(qName)) {
						    	degenerationPoint.setMaterial(model.getMaterial(content.toString()));
						}
						
						// Read "</Area>"
						else if ("Area".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setArea(Double.parseDouble(content.toString()));
							} else {
								StringTokenizer stk = new StringTokenizer(content.toString(), " ");
								double dy = Double.parseDouble(stk.nextToken());
								double dz = Double.parseDouble(stk.nextToken());
								area = new IVolume(dy, dz);
								degenerationPoint.setVolume(area);
							}
						}
						
						// Read "</Ix ...>"
						else if ("Ix".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setIx(Double.parseDouble(content.toString()));
							}
						}
						
						// Read "</Iy ...>"
						else if ("Iy".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setIy(Double.parseDouble(content.toString()));
							}
						}
						
						// Read "</Iz ...>"
						else if ("Iz".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setIz(Double.parseDouble(content.toString()));
							}
						}
						
						// Read "</Height ...>"
						else if ("Height".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setHeight(Double.parseDouble(content.toString()));
							}
						}
						
						// Read "</FormFactorY ...>"
						else if ("FormFactorY".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setFormFactorY(Double.parseDouble(content.toString()));
							}
						}
						
						//Read "</FormFactorZ ...>"
						else if ("FormFactorZ".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setFormFactorZ(Double.parseDouble(content.toString()));
							}
						}
						
						// Read "</Thickness ...>"
						else if ("Thickness".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setThickness(Double.parseDouble(content.toString()));
							}
						}
						
						// Read "</CSMaterial ...>"
						else if ("CSMaterial".equals(qName)) {
							if (dg instanceof PrescribedDegeneration) {
								((PrescribedDegeneration) dg).setMaterial(model.getMaterial(content.toString()));
							}
						}
						
						// ***TAGS FOR ELEMENTS DATA INPUT***
												
						// Read "</ElementList>"
						else if ("ElementList".equals(qName)) {
						}
						
						// Read "</Element>"
						else if ("Element".equals(qName)) {
							model.add(elm);
						}
						
						// Read "</Incidence>"
						else if ("Incidence".equals(qName)) {
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							while (stk.hasMoreTokens()) {
								elm.addNode(model.getNode(stk.nextToken()));
							}
						}
						
						// Read "</IntegrationOrder>"
						else if ("IntegrationOrder".equals(qName)) {
							if (model.getIntegrationOrder(content.toString()) == null) {
								StringTokenizer stk = new StringTokenizer(content.toString(), " ");
								intOr = new IntegrationOrder((int) (Double.parseDouble(stk.nextToken())), (int) (Double.parseDouble(stk.nextToken())), (int) (Double.parseDouble(stk.nextToken())));
								model.add(intOr);

							}
							((ParametricElement) elm).setIntegrationOrder(model.getIntegrationOrder(content.toString()));
						}
						
						// Read "<ConstitutiveModel>"
						else if ("ConstitutiveModel".equals(qName)) {
							if (content.toString().equals("LinearElasticConstModel")) {
								if (model.getConstitutiveModel(content.toString()) == null) {
									cm = new LinearElasticConstModel();
									model.add(cm);
								}
							}
							else if (content.toString().equals("VonMisesConstModel")) {
								if (model.getConstitutiveModel(content.toString()) == null) {
									cm = new VonMisesConstModel();
									model.add(cm);
								}
							}
							else if (content.toString().equals("PolarVonMisesConstModel")) {
								if (model.getConstitutiveModel(content.toString()) == null) {
									cm = new PolarVonMisesConstModel();
									model.add(cm);
								}
							}
							cm = model.getConstitutiveModel(content.toString());
							elm.setConstitutiveModel(cm);
						}
						
						// Read "</ElmDegenerations>"
						else if ("ElmDegenerations".equals(qName)) {
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							while (stk.hasMoreTokens()) {
								elm.addDegeneration(model.getDegeneration(stk.nextToken()));
							}
						}
						
						// Read "</AnalysisModel>"
						else if ("AnalysisModel".equals(qName)) {
							if (content.toString().equals("TimoshenkoSpaceFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new TimoSpaceFrame();
									model.add(anl);
								}
							}
							else if (content.toString().equals("EulerSpaceFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new EulerSpaceFrame();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Axisymmetric")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Axisymmetric();
									model.add(anl);
								}
							}
							else if (content.toString().equals("PlaneStress")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new PlaneStress();
									model.add(anl);
								}
							}

							else if (content.toString().equals("PlaneStrain")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new PlaneStrain();
									model.add(anl);
								}
							}

							else if (content.toString().equals("ReissnerMindlinPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new ReissnerMindlinPlate();
									model.add(anl);
								}
							}

							else if (content.toString().equals("Heterosis")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Heterosis();
									model.add(anl);
								}
							}

							else if (content.toString().equals("MZCKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new MZCKirchhoffPlate();
									model.add(anl);
								}
							}

							else if (content.toString().equals("BFSKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new BFSKirchhoffPlate();
									model.add(anl);
								}
							}

							else if (content.toString().equals("CKZKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new CKZKirchhoffPlate();
									model.add(anl);
								}
							}

							else if (content.toString().equals("CowperKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new CowperKirchhoffPlate();
									model.add(anl);
								}
							}

							else if (content.toString().equals("HCTKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new HCTKirchhoffPlate();
									model.add(anl);
								}
							}

							else if (content.toString().equals("VeubekeKirchhoffPlate")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new VeubekeKirchhoffPlate();
									model.add(anl);
								}
							}
							else if (content.toString().equals("PolarPlaneStrain")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new PolarPlaneStrain();
									model.add(anl);
								}
							}
							else if (content.toString().equals("PolarPlaneStress")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new PolarPlaneStress();
									model.add(anl);
								}
							}
							else if (content.toString().equals("PlaneTruss")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new PlaneTruss();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Beam")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Beam();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Grid")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Grid();
									model.add(anl);
								}
							}
							else if (content.toString().equals("PlaneFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new PlaneFrame();
									model.add(anl);
								}
							}
							else if (content.toString().equals("SpaceTruss")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new SpaceTruss();
									model.add(anl);
								}
							}
							else if (content.toString().equals("SpaceFrame")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new SpaceFrame();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Solid")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Solid();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Line_1D")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Line_1D();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Line_2D")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Line_2D();
									model.add(anl);
								}
							}
							else if (content.toString().equals("Line_3D")) {
								if (model.getAnalysisModel(content.toString()) == null) {
									anl = new Line_3D();
									model.add(anl);
								}
							}
							elm.setAnalysisModel(model.getAnalysisModel(content.toString()));
						}
						
						//***TAGS FOR LOADING DATA INPUT***
						
						// Read "</LoadingList>"
						else if ("LoadingList".equals(qName)) {
						}
						
						// Read "</Loading>"
						else if ("Loading".equals(qName)) {
							model.add(loading);
						}
						
						// Read "</NodeLoad>"
						else if ("NodeLoad".equals(qName)) {
							StringTokenizer stk = new StringTokenizer(content.toString(), " ");
							DoublePointValues dpv = new DoublePointValues();
							int cont = stk.countTokens();
							for (int i = 0; i < cont; i++) {
								dpv.addPointValue(Double.parseDouble(stk.nextToken()));
							}
							loading.setNodalValues(node, dpv);
						}
						
						// ***TAGS FOR LOADSCOMBINATIONS DATA INPUT***
						
						// Read "</LoadCombinations ...>"
						else if ("LoadCombinations".equals(qName)) {
						}
						
						// Read "</LoadCombination ...>"
						else if ("LoadCombination".equals(qName)) {
							model.add(loadComb);
						}
						
						// Read "</LoadCase ...>"
						else if ("LoadCase".equals(qName)) {
							loadComb.add(loadCas);
						}

						// RE-INITIALIZING THE STRINGBUFFER CONTENT
						content = new StringBuffer();

					}
					// END OF ENDELEMENT*********************************************

				});
			// END OF PARSE*******************************************************

		}
		// END OF TRY*******************************************************************
		catch (ParserConfigurationException pce) {
			System.out.println("Could not create that parser.");
			System.out.println(pce.getMessage());
			System.exit(1);
		} catch (SAXException se) {
			System.out.println("Problem with the SAX parser.");
			System.out.println(se.getMessage());
			System.exit(1);
		} catch (IOException ioe) {
			System.out.println("Error reading file.");
			System.out.println(ioe.getMessage());
			System.exit(1);
		}

	}
	// END OF FILLMODELFROMFILE**********************************************************


	// ***********************************************************************************************************

	/*
	 *  (non-Javadoc)
	 *  @see br.ufmg.dees.insane.persistence.Persistence#fillFileFromModel(java.lang.String)
	 */
	public void fillFileFromModel() {

		try {
			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			Document doc = builder.newDocument();

			// Creating formator
			DecimalFormat fmt = new DecimalFormat();
			DecimalFormatSymbols fsym = new DecimalFormatSymbols();
			fsym.setDecimalSeparator('.');
			fmt.setDecimalFormatSymbols(fsym);

			// All the objects which will be serializes are referenced here

			Node node;
			Element elm;
			Material material;
			MaterialPoint degenerationPoint;
			MaterialPoint elemDegenerationPoint;
			Degeneration dg;
			LoadCase loadcase;
			LoadCombination lcomb;
			Loading loading;

			// Creating root DOM element "Insane"
			org.w3c.dom.Element root = doc.createElement("Insane");
			root.setAttribute("xmlns", "http://www.dees.ufmg.br");
			root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
			root.setAttribute("xsi:schemaLocation", "http://www.dees.ufmg.br insane.xsd");
			doc.appendChild(root);

			// ***SOLUTION TREE***

			// Creating DOM element "Solution"
			org.w3c.dom.Element elmSolution = doc.createElement("Solution");
			elmSolution.setAttribute("class", "" + solution.getClass().getSimpleName());
			root.appendChild(elmSolution);

			if (solution.getClass().getName().equals("br.ufmg.dees.insane.solution.EquilibriumPath")) {

				// Creating DOM element "NumMaxSteps"
				org.w3c.dom.Element elmNumberMaxOfSteps = doc.createElement("NumMaxSteps");
				elmNumberMaxOfSteps.appendChild(doc.createTextNode(String.valueOf(((EquilibriumPath) solution).getNumMaxSteps())));
				elmSolution.appendChild(elmNumberMaxOfSteps);

				// Creating DOM element "Step"
				org.w3c.dom.Element elmStep = doc.createElement("Step");
				elmStep.setAttribute("class", "" + ((EquilibriumPath) solution).getStep().getClass().getSimpleName());
				elmSolution.appendChild(elmStep);

				// Creating DOM element "NumMaxIterations"
				org.w3c.dom.Element elmNumberMaxIterations = doc.createElement("NumMaxIterations");
				elmNumberMaxIterations.appendChild(doc.createTextNode(String.valueOf(((EquilibriumPath) solution).getStep().getNumMaxIterations())));
				elmStep.appendChild(elmNumberMaxIterations);

				// Creating DOM element "Tolerance"
				org.w3c.dom.Element elmTolerance = doc.createElement("Tolerance");
				elmTolerance.appendChild(doc.createTextNode(String.valueOf(((EquilibriumPath) solution).getStep().getTolerance())));
				elmStep.appendChild(elmTolerance);

				// Creating DOM element "ConvergenceType"
				org.w3c.dom.Element elmConvergenceType = doc.createElement("ConvergenceType");
				elmConvergenceType.appendChild(doc.createTextNode(String.valueOf(((EquilibriumPath) solution).getStep().getConvType())));
				elmStep.appendChild(elmConvergenceType);

				// Creating DOM element "IteractiveStrategyList"
				org.w3c.dom.Element elmIteractiveStrategyList = doc.createElement("IteractiveStrategyList");
				elmSolution.appendChild(elmIteractiveStrategyList);

				// Creating DOM elements "IteractiveStrategy"
				for (int i = 0; i < ((EquilibriumPath) solution).getIteracStrategy().length; i++) {
					org.w3c.dom.Element elmIteractiveStrategy = doc.createElement("IteractiveStrategy");
					elmIteractiveStrategy.setAttribute("class", "" + ((EquilibriumPath) solution).getIteracStrategy()[i].getClass().getSimpleName());
					elmIteractiveStrategy.setAttribute("LoadFactor", "" + ((EquilibriumPath) solution).getIteracStrategy()[i].getLoadFactor());
					elmIteractiveStrategyList.appendChild(elmIteractiveStrategy);

					if (((EquilibriumPath) solution).getIteracStrategy()[i].getClass().getSimpleName().equals("DisplacementControl")) {

						// Creating DOM element "NodeControl"
						org.w3c.dom.Element elmNodeControl = doc.createElement("NodeControl");
						elmNodeControl.appendChild(doc.createTextNode(String.valueOf(((DisplacementControl) ((EquilibriumPath) solution).getIteracStrategy()[i]).getNodeControl())));
						elmIteractiveStrategy.appendChild(elmNodeControl);

						// Creating DOM element "DirectionControl"
						org.w3c.dom.Element elmDirectionControl = doc.createElement("DirectionControl");
						elmDirectionControl.appendChild(doc.createTextNode(String.valueOf(((DisplacementControl) ((EquilibriumPath) solution).getIteracStrategy()[i]).getDirectionControl())));
						elmIteractiveStrategy.appendChild(elmDirectionControl);

					}
				}

				// Creating DOM element "ChangeLoadFactor"
				org.w3c.dom.Element elmChangeLoadFactor = doc.createElement("ChangeLoadFactor");
				fmt.applyPattern("0.000E00");
				elmChangeLoadFactor.appendChild(doc.createTextNode(String.valueOf(fmt.format(((EquilibriumPath) solution).getchangeLoadFactor()))));
				elmSolution.appendChild(elmChangeLoadFactor);

				// Creating DOM element "ChangeTolerance"
				org.w3c.dom.Element elmChangeTolerance = doc.createElement("ChangeTolerance");
				fmt.applyPattern("0.000E00");
				elmChangeTolerance.appendChild(doc.createTextNode(String.valueOf(fmt.format(((EquilibriumPath) solution).getchangeTolerance()))));
				elmSolution.appendChild(elmChangeTolerance);

				// Creating DOM element "ChangeNumMaxIterations"
				org.w3c.dom.Element elmChangeNumMaxIterations = doc.createElement("ChangeNumMaxIterations");
				elmChangeNumMaxIterations.appendChild(doc.createTextNode(String.valueOf(((EquilibriumPath) solution).getchangeNumMaxIterations())));
				elmSolution.appendChild(elmChangeNumMaxIterations);

				// Creating DOM element "StepNumber"
				org.w3c.dom.Element elmStepNumber = doc.createElement("StepNumber");
				elmStepNumber.appendChild(doc.createTextNode(String.valueOf(((EquilibriumPath) solution).getStep().getLabel())));
				elmSolution.appendChild(elmStepNumber);

				// Creating DOM element "FinalLoadFactor"
				org.w3c.dom.Element elmFinalLoadFactor = doc.createElement("FinalLoadFactor");
				fmt.applyPattern("0.000E00");
				elmFinalLoadFactor.appendChild(doc.createTextNode(String.valueOf(fmt.format(((EquilibriumPath) solution).getStep().getLoadFactorTotal()))));
				elmSolution.appendChild(elmFinalLoadFactor);
			}

			// ***MODEL TREE***

			// Creating DOM element "Model"
			org.w3c.dom.Element elmModel = doc.createElement("Model");
			elmModel.setAttribute("class", "" + model.getClass().getSimpleName());
			root.appendChild(elmModel);

			// Creating DOM element "ProblemDriver"
			org.w3c.dom.Element elmProblemDriver = doc.createElement("ProblemDriver");
			elmProblemDriver.appendChild(doc.createTextNode(String.valueOf(model.getProblemDriver().getClass().getSimpleName())));
			elmModel.appendChild(elmProblemDriver);

			// Creating DOM element "GlobalAnalysisModel"
			org.w3c.dom.Element elmGlobalAnalysisModel = doc.createElement("GlobalAnalysisModel");
			elmGlobalAnalysisModel.appendChild(doc.createTextNode(String.valueOf(model.getGlobalAnalysisModel().getLabel())));
			elmModel.appendChild(elmGlobalAnalysisModel);

			// ***MATERIALS TREE***

			// Creating DOM element "MaterialList"
			org.w3c.dom.Element elmMaterialList = doc.createElement("MaterialList");
			elmModel.appendChild(elmMaterialList);

			// Creating DOM elements "Material"
			ListIterator materials = model.getMaterialsList().listIterator();
			while (materials.hasNext()) {
				material = (Material) materials.next();
				org.w3c.dom.Element elmMaterial = doc.createElement("Material");
				elmMaterial.setAttribute("class", "" + material.getClass().getSimpleName());
				elmMaterial.setAttribute("label", "" + material.getLabel());
				elmMaterialList.appendChild(elmMaterial);

				if (material.getClass().equals("LinearElasticIsotropic")
						 || material.getClass().equals("PolarLinearElasticIsotropic")) {
				}

				if (material.getMaterialValues().containsKey("ELASTICITY")) {
					// Creating DOM element "Elasticity"
					org.w3c.dom.Element elmElasticity = doc.createElement("Elasticity");
					elmElasticity.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ELASTICITY"))));
					elmMaterial.appendChild(elmElasticity);
				}

				if (material.getMaterialValues().containsKey("ELASTICITY2")) {
					// Creating DOM element "Elasticity2"
					org.w3c.dom.Element elmElasticity2 = doc.createElement("Elasticity2");
					elmElasticity2.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ELASTICITY2"))));
					elmMaterial.appendChild(elmElasticity2);
				}

				if (material.getMaterialValues().containsKey("ELASTICITY11")) {
					// Creating DOM element "Elasticity11"
					org.w3c.dom.Element elmElasticity11 = doc.createElement("Elasticity11");
					elmElasticity11.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ELASTICITY11"))));
					elmMaterial.appendChild(elmElasticity11);
				}

				if (material.getMaterialValues().containsKey("ELASTICITY22")) {
					// Creating DOM element "Elasticity22"
					org.w3c.dom.Element elmElasticity22 = doc.createElement("Elasticity22");
					elmElasticity22.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ELASTICITY22"))));
					elmMaterial.appendChild(elmElasticity22);
				}

				if (material.getMaterialValues().containsKey("ELASTICITY33")) {
					// Creating DOM element "Elasticity33"
					org.w3c.dom.Element elmElasticity33 = doc.createElement("Elasticity33");
					elmElasticity33.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ELASTICITY33"))));
					elmMaterial.appendChild(elmElasticity33);
				}

				if (material.getMaterialValues().containsKey("POISSON")) {
					// Creating DOM element "Poisson"
					org.w3c.dom.Element elmPoisson = doc.createElement("Poisson");
					elmPoisson.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("POISSON"))));
					elmMaterial.appendChild(elmPoisson);
				}

				if (material.getMaterialValues().containsKey("POISSON12")) {
					// Creating DOM element "Poisson12"
					org.w3c.dom.Element elmPoisson12 = doc.createElement("Poisson12");
					elmPoisson12.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("POISSON12"))));
					elmMaterial.appendChild(elmPoisson12);
				}

				if (material.getMaterialValues().containsKey("POISSON13")) {
					// Creating DOM element "Poisson13"
					org.w3c.dom.Element elmPoisson13 = doc.createElement("Poisson13");
					elmPoisson13.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("POISSON13"))));
					elmMaterial.appendChild(elmPoisson13);
				}

				if (material.getMaterialValues().containsKey("POISSON23")) {
					// Creating DOM element "Poisson23"
					org.w3c.dom.Element elmPoisson23 = doc.createElement("Poisson23");
					elmPoisson23.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("POISSON23"))));
					elmMaterial.appendChild(elmPoisson23);
				}

				if (material.getMaterialValues().containsKey("SHEAR_MODULUS")) {
					// Creating DOM element "ShearModulus"
					org.w3c.dom.Element elmShearModulus = doc.createElement("ShearModulus");
					elmShearModulus.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("SHEAR_MODULUS"))));
					elmMaterial.appendChild(elmShearModulus);
				}
				
				if (material.getMaterialValues().containsKey("THERMAL_COEFF")) {
					// Creating DOM element "ThermalCoeff"
					org.w3c.dom.Element elmThermalCoeff = doc.createElement("ThermalCoeff");
					elmThermalCoeff.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("THERMAL_COEFF"))));
					elmMaterial.appendChild(elmThermalCoeff);
				}
				
				if (material.getMaterialValues().containsKey("YIELDING")) {
					// Creating DOM element "Yielding"
					org.w3c.dom.Element elmYielding = doc.createElement("Yielding");
					elmYielding.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("YIELDING"))));
					elmMaterial.appendChild(elmYielding);
				}

				if (material.getMaterialValues().containsKey("HARDENING_MODULUS")) {
					// Creating DOM element "HardeningModulus"
					org.w3c.dom.Element elmHardeningModulus = doc.createElement("HardeningModulus");
					elmHardeningModulus.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("HARDENING_MODULUS"))));
					elmMaterial.appendChild(elmHardeningModulus);
				}
				
				if (material.getMaterialValues().containsKey("Fck")) {
					// Creating DOM element "Fck"
					org.w3c.dom.Element elmFck = doc.createElement("Fck");
					elmFck.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Fck"))));
					elmMaterial.appendChild(elmFck);
				}

				if (material.getMaterialValues().containsKey("Fc")) {
					// Creating DOM element "Fc"
					org.w3c.dom.Element elmFc = doc.createElement("Fc");
					elmFc.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Fc"))));
					elmMaterial.appendChild(elmFc);
				}

				if (material.getMaterialValues().containsKey("Ft")) {
					// Creating DOM element "Ft"
					org.w3c.dom.Element elmFt = doc.createElement("Ft");
					elmFt.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Ft"))));
					elmMaterial.appendChild(elmFt);
				}
				
				if (material.getMaterialValues().containsKey("ec")) {
					// Creating DOM element "ec"
					org.w3c.dom.Element elmec = doc.createElement("ec");
					elmec.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ec"))));
					elmMaterial.appendChild(elmec);
				}

				if (material.getMaterialValues().containsKey("et")) {
					// Creating DOM element "et"
					org.w3c.dom.Element elmet = doc.createElement("et");
					elmet.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("et"))));
					elmMaterial.appendChild(elmet);
				}

				if (material.getMaterialValues().containsKey("E0")) {
					// Creating DOM element "E0"
					org.w3c.dom.Element elmE0 = doc.createElement("E0");
					elmE0.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("E0"))));
					elmMaterial.appendChild(elmE0);
				}
				
				if (material.getMaterialValues().containsKey("Ec0")) {
					// Creating DOM element "Ec0"
					org.w3c.dom.Element elmEc0 = doc.createElement("Ec0");
					elmEc0.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Ec0"))));
					elmMaterial.appendChild(elmEc0);
				}
				if (material.getMaterialValues().containsKey("Ecm")) {
					// Creating DOM element "Ecm"
					org.w3c.dom.Element elmEcm = doc.createElement("Ecm");
					elmEcm.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Ecm"))));
					elmMaterial.appendChild(elmEcm);
				}

				if (material.getMaterialValues().containsKey("Fcm")) {
					// Creating DOM element "Fcm"
					org.w3c.dom.Element elmFcm = doc.createElement("Fcm");
					elmFcm.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Fcm"))));
					elmMaterial.appendChild(elmFcm);
				}

				if (material.getMaterialValues().containsKey("Dc1")) {
					// Creating DOM element "Dc1"
					org.w3c.dom.Element elmDc1 = doc.createElement("Dc1");
					elmDc1.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Dc1"))));
					elmMaterial.appendChild(elmDc1);
				}

				if (material.getMaterialValues().containsKey("Dcu")) {
					// Creating DOM element "Dcu"
					org.w3c.dom.Element elmDcu = doc.createElement("Dcu");
					elmDcu.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("Dcu"))));
					elmMaterial.appendChild(elmDcu);
				}

				if (material.getMaterialValues().containsKey("LENGTH_BENDING")) {
					// Creating DOM element "LengthBending"
					org.w3c.dom.Element elmLengthBending = doc.createElement("LengthBending");
					elmLengthBending.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("LENGTH_BENDING"))));
					elmMaterial.appendChild(elmLengthBending);
				}

				if (material.getMaterialValues().containsKey("LENGTH_TORSION")) {
					// Creating DOM element "LengthTorsion"
					org.w3c.dom.Element elmLengthTorsion = doc.createElement("LengthTorsion");
					elmLengthTorsion.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("LENGTH_TORSION"))));
					elmMaterial.appendChild(elmLengthTorsion);
				}
				
				if (material.getMaterialValues().containsKey("ALPHA")) {
					// Creating DOM element "Alpha"
					org.w3c.dom.Element elmAlpha = doc.createElement("Alpha");
					elmAlpha.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ALPHA"))));
					elmMaterial.appendChild(elmAlpha);
				}

				if (material.getMaterialValues().containsKey("ETA")) {
					// Creating DOM element "Eta"
					org.w3c.dom.Element elmEta = doc.createElement("Eta");
					elmEta.appendChild(doc.createTextNode(String.valueOf(material.getMaterialValues("ETA"))));
					elmMaterial.appendChild(elmEta);
				}
				
			}

			// ***DEGENERATIONS TREE***

			// Creating DOM element "DegenerationList"
			org.w3c.dom.Element elmDegenerationList = doc.createElement("DegenerationList");
			elmModel.appendChild(elmDegenerationList);
			
			// Creating DOM elements "Degeneration"
			ListIterator dgns = model.getDegenerationsList().listIterator();
			while (dgns.hasNext()) {
			    	
				dg = (Degeneration) dgns.next();
				org.w3c.dom.Element elmDegeneration = doc.createElement("Degeneration");
				elmDegeneration.setAttribute("class", "" + dg.getClass().getSimpleName());
				elmDegeneration.setAttribute("label", "" + dg.getOriginalLabel());
				elmDegenerationList.appendChild(elmDegeneration);

				// Creating DOM elements "DegenerationPoint"
				ListIterator pnts = dg.getMaterialPoints().listIterator();
				int k = 1;
				while (pnts.hasNext()) {
					degenerationPoint = (MaterialPoint) pnts.next();

					org.w3c.dom.Element elmDegenerationPoint = doc.createElement("DegenerationPoint");
					elmDegenerationPoint.setAttribute("SectionCoord", "" + (String.valueOf(fmt.format(degenerationPoint.getPoint().y))) + " " + (String.valueOf(fmt.format(degenerationPoint.getPoint().z))));
					elmDegenerationPoint.setAttribute("label", "" + k);
					elmDegeneration.appendChild(elmDegenerationPoint);

					// Creating DOM element "PointMaterial"
					org.w3c.dom.Element elmPointMaterial = doc.createElement("PointMaterial");
					elmPointMaterial.appendChild(doc.createTextNode(degenerationPoint.getMaterial().getLabel()));
					elmDegenerationPoint.appendChild(elmPointMaterial);

					// Creating DOM element "PointAnalysisModel"
					org.w3c.dom.Element elmPointAnalysisModel = doc.createElement("PointAnalysisModel");
					elmPointAnalysisModel.appendChild(doc.createTextNode(degenerationPoint.getContinuousPointModel().getLabel()));
					elmDegenerationPoint.appendChild(elmPointAnalysisModel);
					
					// Creating DOM element "PointConstitutiveModel"
					org.w3c.dom.Element elmPointConstitutiveModel = doc.createElement("PointConstitutiveModel");
					elmPointConstitutiveModel.appendChild(doc.createTextNode(degenerationPoint.getCm().getLabel()));
					elmDegenerationPoint.appendChild(elmPointConstitutiveModel);
					
					// Creating DOM elements "Area"
					org.w3c.dom.Element elmPointArea = doc.createElement("Area");
					fmt.applyPattern("0.000E00");
					elmPointArea.appendChild(doc.createTextNode(String.valueOf(fmt.format(degenerationPoint.getVolume().dy)) + " " + String.valueOf(fmt.format(degenerationPoint.getVolume().dz))));
					elmDegenerationPoint.appendChild(elmPointArea);
					
					k++;
				}
				
				if (dg instanceof PrescribedDegeneration) {

					// Creating DOM elements "Area"
				    	if (((PrescribedDegeneration) dg).getArea() != 0 ) {
				    	    org.w3c.dom.Element elmArea = doc.createElement("Area");
				    	    fmt.applyPattern("##0.000");
				    	    elmArea.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getArea()))));
				    	    elmDegeneration.appendChild(elmArea);   
				    	}

					// Creating DOM elements "Ix"
				    	if (((PrescribedDegeneration) dg).getIx() != 0 ) {
				    	    org.w3c.dom.Element elmIx = doc.createElement("Ix");
				    	    fmt.applyPattern("0.000E00");
				    	    elmIx.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getIx()))));
				    	    elmDegeneration.appendChild(elmIx);
				    	}

					// Creating DOM elements "Iy"
				    	if (((PrescribedDegeneration) dg).getIy() != 0 ) {
				    	    org.w3c.dom.Element elmIy = doc.createElement("Iy");
				    	    fmt.applyPattern("0.000E00");
        				    elmIy.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getIy()))));
        				    elmDegeneration.appendChild(elmIy);
				    	}

					// Creating DOM elements "Iz"
					if (((PrescribedDegeneration) dg).getIz() != 0 ) {
					    org.w3c.dom.Element elmIz = doc.createElement("Iz");
					    fmt.applyPattern("0.000E00");
					    elmIz.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getIz()))));
					    elmDegeneration.appendChild(elmIz);
					}

					// Creating DOM elements "Height"
					if (((PrescribedDegeneration) dg).getHeight() != 0 ) {
    					    org.w3c.dom.Element elmHeight = doc.createElement("Height");
    					    fmt.applyPattern("##0.000");
    					    elmHeight.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getHeight()))));
    					    elmDegeneration.appendChild(elmHeight);
					}
					
					// Creating DOM elements "CSMaterial"
					org.w3c.dom.Element elmCSMaterial = doc.createElement("CSMaterial");
					elmCSMaterial.appendChild(doc.createTextNode(((PrescribedDegeneration) dg).getMaterial().getLabel()));
					elmDegeneration.appendChild(elmCSMaterial);
					
					// Creating DOM elements "Height"
					if (((PrescribedDegeneration) dg).getHeight() != 0 ) {
					    org.w3c.dom.Element elmThickness = doc.createElement("Thickness");
					    fmt.applyPattern("##0.000");
					    elmThickness.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getThickness()))));
					    elmDegeneration.appendChild(elmThickness);
					}
					
					// Creating DOM elements "FormFactorY"
					org.w3c.dom.Element elmFy = doc.createElement("FormFactorY");
					fmt.applyPattern("##0.000");
					elmFy.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getFormFactorY()))));
					elmDegeneration.appendChild(elmFy);

					// Creating DOM elements "FormFactorZ"
					org.w3c.dom.Element elmFz = doc.createElement("FormFactorZ");
					fmt.applyPattern("##0.000");
					elmFz.appendChild(doc.createTextNode(String.valueOf(fmt.format(((PrescribedDegeneration) dg).getFormFactorZ()))));
					elmDegeneration.appendChild(elmFz);

				} else {

					// Creating DOM elements "GeometricProperties"
					org.w3c.dom.Element elmSectionProps = doc.createElement("GeometricProperties");
					elmDegeneration.appendChild(elmSectionProps);
					
					GeometricProperties props = dg.getGeometricProperties();

					// Creating DOM elements "SectionArea"
					if (props.getArea() != 0) {
        					org.w3c.dom.Element elmSectionArea = doc.createElement("SectionArea");
        					fmt.applyPattern("0.000E00");
        					elmSectionArea.appendChild(doc.createTextNode(String.valueOf(fmt.format(props.getArea()))));
        					elmSectionProps.appendChild(elmSectionArea);
					}

					// Creating DOM elements "InertiaX"
					if (props.getInertiaX() != 0) {
					    org.w3c.dom.Element elmSectionInertiaX = doc.createElement("InertiaX");
					    fmt.applyPattern("0.000E00");
					    elmSectionInertiaX.appendChild(doc.createTextNode(String.valueOf(fmt.format(props.getInertiaX()))));
					    elmSectionProps.appendChild(elmSectionInertiaX);
					}
					
					// Creating DOM elements "InertiaY"
					if (props.getInertiaY() != 0) {
					    org.w3c.dom.Element elmSectionInertiaY = doc.createElement("InertiaY");
					    fmt.applyPattern("0.000E00");
					    elmSectionInertiaY.appendChild(doc.createTextNode(String.valueOf(fmt.format(props.getInertiaY()))));
					    elmSectionProps.appendChild(elmSectionInertiaY);
					}

					// Creating DOM elements "InertiaZ"
					if (props.getInertiaZ() != 0) {
					    org.w3c.dom.Element elmSectionInertiaZ = doc.createElement("InertiaZ");
					    fmt.applyPattern("0.000E00");
					    elmSectionInertiaZ.appendChild(doc.createTextNode(String.valueOf(fmt.format(props.getInertiaZ()))));
					    elmSectionProps.appendChild(elmSectionInertiaZ);
					}
					

					// Creating DOM elements "SectionThickness"
					if (props.getThickness() != 0) {
					    org.w3c.dom.Element elmThickness = doc.createElement("SectionThickness");
					    fmt.applyPattern("0.000E00");
					    elmThickness.appendChild(doc.createTextNode(String.valueOf(fmt.format(props.getThickness()))));
					    elmSectionProps.appendChild(elmThickness);
					}
					
				}

			}
			// End of creating DOM elements "CrossSection"

			// ***NODES TREE***

			// Creating DOM element "NodeList"
			org.w3c.dom.Element elmNodeList = doc.createElement("NodeList");
			elmModel.appendChild(elmNodeList);

			// Creating DOM elements "Node"
			ListIterator nodes = model.getNodesList().listIterator();
			while (nodes.hasNext()) {
				node = (Node) nodes.next();
				org.w3c.dom.Element elmNode = doc.createElement("Node");
				elmNode.setAttribute("label", "" + node.getLabel());
				elmNodeList.appendChild(elmNode);

				// Creating DOM elements "Coord"
				org.w3c.dom.Element elmCoord = doc.createElement("Coord");
				fmt.applyPattern("0.000E00");
				elmCoord.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getPoint().x))));
				elmCoord.appendChild(doc.createTextNode(" "));
				elmCoord.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getPoint().y))));
				elmCoord.appendChild(doc.createTextNode(" "));
				elmCoord.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getPoint().z))));
				elmNode.appendChild(elmCoord);

				// Creating DOM element "NodeValues"
				org.w3c.dom.Element elmNodeValues = doc.createElement("NodeValues");
				elmNode.appendChild(elmNodeValues);
				
				// Creating DOM elements "Labels"
				if (node.nodeValuesContainsKey(node.DOF_LABELS)) {
					org.w3c.dom.Element elmLabels = doc.createElement("DOFLabels");
					for (int i = 0; i < node.getNumberOfDegreesOfFreedom(); i++) {
						elmLabels.appendChild(doc.createTextNode(String.valueOf(node.getNodeValues(node.DOF_LABELS).getStringPointValue(i))));
						if (i != node.getNumberOfDegreesOfFreedom() - 1) {
							elmLabels.appendChild(doc.createTextNode(" "));
						}
					}
					elmNodeValues.appendChild(elmLabels);
				}
				
				// Creating DOM elements "Restraints"
				if (node.nodeValuesContainsKey(node.RESTRAINTS)) {
					org.w3c.dom.Element elmRestraints = doc.createElement("Restraints");
					for (int i = 0; i < node.getNumberOfDegreesOfFreedom(); i++) {
						elmRestraints.appendChild(doc.createTextNode(String.valueOf(node.getNodeValues(node.RESTRAINTS).getBooleanPointValue(i))));
						if (i != node.getNumberOfDegreesOfFreedom() - 1) {
							elmRestraints.appendChild(doc.createTextNode(" "));
						}
					}
					elmNodeValues.appendChild(elmRestraints);
				}

				// Creating DOM elements "PreDisplacement"
				if (node.nodeValuesContainsKey(Node.PRE_STATE_VARIABLE)) {
					org.w3c.dom.Element elmPreDisplacements = doc.createElement("PreDisplacements");
					fmt.applyPattern("0.000E00");
					for (int i = 0; i < node.getNumberOfDegreesOfFreedom(); i++) {
						elmPreDisplacements.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getNodeValues(Node.PRE_STATE_VARIABLE).getDoublePointValue(i)))));
						elmPreDisplacements.appendChild(doc.createTextNode(" "));
					}
					elmNodeValues.appendChild(elmPreDisplacements);
				}

				// Creating DOM element "Coeficients"
				if (node.nodeValuesContainsKey(node.COEFICIENTS_C)) {
					org.w3c.dom.Element elmMySpring = doc.createElement("Coeficients");
					fmt.applyPattern("0.000E00");
					for (int i = 0; i < node.getNumberOfDegreesOfFreedom(); i++) {
						elmMySpring.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getNodeValues(node.COEFICIENTS_C).getDoublePointValue(i)))));
						elmMySpring.appendChild(doc.createTextNode(" "));
					}
					elmNodeValues.appendChild(elmMySpring);
				}


				// Creating DOM elements "Displacements"
				if (node.nodeValuesContainsKey(Node.STATE_VARIABLE)) {
					org.w3c.dom.Element elmDisplacements = doc.createElement("Displacements");
					fmt.applyPattern("0.000E00");
					for (int i = 0; i < node.getNumberOfDegreesOfFreedom(); i++) {
						elmDisplacements.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getNodeValues(Node.STATE_VARIABLE).getDoublePointValue(i)))));
						if (i != node.getNumberOfDegreesOfFreedom() - 1) {
							elmDisplacements.appendChild(doc.createTextNode(" "));
						}
					}
					elmNodeValues.appendChild(elmDisplacements);
				}
				
				// Creating DOM elements "Reactions"
				if (node.nodeValuesContainsKey(Node.UNKNOWN_DUAL_VARIABLE)) {
					org.w3c.dom.Element elmReactions = doc.createElement("Reactions");
					fmt.applyPattern("0.000E00");
					for (int i = 0; i < node.getNumberOfDegreesOfFreedom(); i++) {
						elmReactions.appendChild(doc.createTextNode(String.valueOf(fmt.format(node.getNodeValues(Node.UNKNOWN_DUAL_VARIABLE).getDoublePointValue(i)))));
						if (i != node.getNumberOfDegreesOfFreedom() - 1) {
							elmReactions.appendChild(doc.createTextNode(" "));
						}
					}
					elmNodeValues.appendChild(elmReactions);
				}
			}
			// End of creating DOM element "Node"

			// ***ELEMENTS TREE***

			// Creating DOM element "ElementList"
			org.w3c.dom.Element elmElementList = doc.createElement("ElementList");
			elmModel.appendChild(elmElementList);

			// Creating DOM elements "Element"
			ListIterator elms = model.getElementsList().listIterator();
			while (elms.hasNext()) {
				elm = (Element) elms.next();
				org.w3c.dom.Element elmElement = doc.createElement("Element");
				if (elm instanceof FrameElement) {
					elmElement.setAttribute("class", "" + elm.getClass().getSimpleName() + "." + elm.getShape().getClass().getSimpleName());
				} else {
					elmElement.setAttribute("class", "" + elm.getClass().getSuperclass().getSimpleName() + "." + elm.getClass().getSimpleName() + "." + elm.getShape().getClass().getSimpleName());
				}
				elmElement.setAttribute("label", "" + elm.getLabel());
				elmElementList.appendChild(elmElement);

				// Creating DOM element "Incidence"
				org.w3c.dom.Element elmIncidence = doc.createElement("Incidence");
				ListIterator elementNodes = elm.getIncidence().listIterator();
				while (elementNodes.hasNext()) {
					ElementNode en = (ElementNode) elementNodes.next();
					elmIncidence.appendChild(doc.createTextNode(String.valueOf(en.getNode().getLabel())));
					if (elementNodes.hasNext()) {
						elmIncidence.appendChild(doc.createTextNode(" "));
					}
					elmElement.appendChild(elmIncidence);
				}

				// Creating DOM element "AnalysisModel"
				org.w3c.dom.Element elmElementAnalysisModel = doc.createElement("AnalysisModel");
				elmElementAnalysisModel.appendChild(doc.createTextNode(elm.getAnalysisModel().getLabel()));
				elmElement.appendChild(elmElementAnalysisModel);

				// Creating DOM element "IntegrationOrder"
				if (elm instanceof ParametricElement) {
					org.w3c.dom.Element elmIntegOrder = doc.createElement("IntegrationOrder");
					elmIntegOrder.appendChild(doc.createTextNode(String.valueOf(((ParametricElement) elm).getIntegrationOrder().getXiIntegOrder())));
					elmIntegOrder.appendChild(doc.createTextNode(" "));
					elmIntegOrder.appendChild(doc.createTextNode(String.valueOf(((ParametricElement) elm).getIntegrationOrder().getEtaIntegOrder())));
					elmIntegOrder.appendChild(doc.createTextNode(" "));
					elmIntegOrder.appendChild(doc.createTextNode(String.valueOf(((ParametricElement) elm).getIntegrationOrder().getZetaIntegOrder())));
					elmElement.appendChild(elmIntegOrder);
				}

				if (!(elm.getConstitutiveModel() == null)) {
					// Creating DOM element "ConstitutiveModel"
					org.w3c.dom.Element elmElementConstitutiveModel = doc.createElement("ConstitutiveModel");
					elmElementConstitutiveModel.appendChild(doc.createTextNode(elm.getConstitutiveModel().getLabel()));
					elmElement.appendChild(elmElementConstitutiveModel);
				}

				// ***ELEMENTS' DEGENERATIONS TREE***

				// Creating DOM element "ElmDegenerations"
				org.w3c.dom.Element elmElmDegenerations = doc.createElement("ElmDegenerations");
				ListIterator elemDgns = elm.getDegenerations().listIterator();
				String sections = new String();
				while (elemDgns.hasNext()) {
					dg = (Degeneration) elemDgns.next();
					sections += dg.getOriginalLabel();
					if (elemDgns.hasNext()) {
						sections += " ";
					}
				}
				elmElmDegenerations.appendChild(doc.createTextNode(sections));
				elmElement.appendChild(elmElmDegenerations);

				//Creating DOM elements "IntVarLabels"
				org.w3c.dom.Element elmIntVarLabels = doc.createElement("IntVarLabels");
				String[] labels = elm.getAnalysisModel().getInternalVariablesLabels();
				for (int i = 0; i < elm.getAnalysisModel().getNumberOfInternalVariables(); i++) {
					elmIntVarLabels.appendChild(doc.createTextNode(labels[i]));
					if (i != elm.getAnalysisModel().getNumberOfInternalVariables() - 1) {
						elmIntVarLabels.appendChild(doc.createTextNode(" "));
					}
				}
				elmElement.appendChild(elmIntVarLabels);

				//Creating DOM elements "DualIntVarLabels"
				org.w3c.dom.Element DualIntVarLabels = doc.createElement("DualIntVarLabels");
				String[] labels2 = elm.getAnalysisModel().getDualInternalVariablesLabels();
				for (int i = 0; i < elm.getAnalysisModel().getNumberOfDualInternalVariables(); i++) {
					DualIntVarLabels.appendChild(doc.createTextNode(labels2[i]));
					if (i != elm.getAnalysisModel().getNumberOfDualInternalVariables() - 1) {
						DualIntVarLabels.appendChild(doc.createTextNode(" "));
					}
				}
				elmElement.appendChild(DualIntVarLabels);

				if(elm.getDegenerations().size() != 0 ) {
				
					// Creating DOM element "ElmDegenerationList"
					org.w3c.dom.Element elmElmDegenerationList = doc.createElement("ElmDegenerationList");
					elmElement.appendChild(elmElmDegenerationList);
					
					// Creating DOM elements "ElmDegeneration"
					ListIterator elemDgns2 = elm.getDegenerations().listIterator();
					while (elemDgns2.hasNext()) {
	
						dg = (Degeneration) elemDgns2.next();
	
						if (!(dg instanceof PrescribedDegeneration)) {
	
							org.w3c.dom.Element elmElmDegeneration = doc.createElement("ElmDegeneration");
							elmElmDegeneration.setAttribute("label", "" + dg.getLabel());
							elmElmDegenerationList.appendChild(elmElmDegeneration);
	
							// Creating DOM elements "IPCoord"
							org.w3c.dom.Element elmIPCoord = doc.createElement("IPCoord");
							fmt.applyPattern("0.000E00");
							IVector ipCoords = elm.getCartesianPointCoords(dg.getRepresentation().getNaturalcoords().toDouble());
							for (int i = 0; i < ipCoords.getSize(); i++) {
								elmIPCoord.appendChild(doc.createTextNode(String.valueOf(fmt.format(ipCoords.getElement(i)))));
								elmIPCoord.appendChild(doc.createTextNode(" "));
							}
							elmElmDegeneration.appendChild(elmIPCoord);
	
							// Creating DOM elements "GeneralizedStrains"
							org.w3c.dom.Element elmSectionStrain = doc.createElement("GeneralizedStrains");
							fmt.applyPattern("0.000E00");
							IVector intvar = elm.getPointInternalVariables(dg);
							for (int i = 0; i < elm.getAnalysisModel().getNumberOfInternalVariables(); i++) {
								elmSectionStrain.appendChild(doc.createTextNode(String.valueOf(fmt.format(intvar.getElement(i)))));
								elmSectionStrain.appendChild(doc.createTextNode(" "));
							}
							elmElmDegeneration.appendChild(elmSectionStrain);
	
							// Creating DOM elements "GeneralizedStresses"
							org.w3c.dom.Element elmSectionStress = doc.createElement("GeneralizedStresses");
							fmt.applyPattern("0.000E00");
							IVector dualintvar = (IVector) dg.mountDualInternalVariableVector(intvar);
							for (int i = 0; i < elm.getAnalysisModel().getNumberOfDualInternalVariables(); i++) {
								elmSectionStress.appendChild(doc.createTextNode(String.valueOf(fmt.format(dualintvar.getElement(i)))));
								elmSectionStress.appendChild(doc.createTextNode(" "));
							}
							elmElmDegeneration.appendChild(elmSectionStress);
	
							//Creating DOM elements "MPIntVarLabels"
							org.w3c.dom.Element elmMPIntVarLabels = doc.createElement("MPIntVarLabels");
							String[] labels3 = dg.getMaterialPoint(0).getContinuousPointModel().getInternalVariablesLabels();
							for (int i = 0; i < dg.getMaterialPoint(0).getContinuousPointModel().getNumberOfInternalVariables(); i++) {
								elmMPIntVarLabels.appendChild(doc.createTextNode((labels3[i] + " ")));
								elmMPIntVarLabels.appendChild(doc.createTextNode(" "));
							}
							elmElmDegeneration.appendChild(elmMPIntVarLabels);
	
							//Creating DOM elements "MPDualIntVarLabels"
							org.w3c.dom.Element MPDualIntVarLabels = doc.createElement("MPDualIntVarLabels");
							String[] labels4 = dg.getMaterialPoint(0).getContinuousPointModel().getDualInternalVariablesLabels();
							for (int i = 0; i < dg.getMaterialPoint(0).getContinuousPointModel().getNumberOfDualInternalVariables(); i++) {
								MPDualIntVarLabels.appendChild(doc.createTextNode((labels4[i] + " ")));
							}
							elmElmDegeneration.appendChild(MPDualIntVarLabels);
	
							// Creating DOM elements "SectionPoint"
							ListIterator pnts = dg.getMaterialPoints().listIterator();
							while (pnts.hasNext()) {
								elemDegenerationPoint = (MaterialPoint) pnts.next();
								org.w3c.dom.Element elmSectionPoint = doc.createElement("SectionPoint");
								elmSectionPoint.setAttribute("label", "" + elemDegenerationPoint.getLabel());
								elmElmDegeneration.appendChild(elmSectionPoint);
	
								// Creating DOM elements "Strains"
								org.w3c.dom.Element elmPointStrain = doc.createElement("Strains");
								fmt.applyPattern("0.000E00");
								IVector strain = elm.getMPInternalVariables(dg, elemDegenerationPoint.getLabel());
								for (int i = 0; i < elemDegenerationPoint.getContinuousPointModel().getNumberOfInternalVariables(); i++) {
									elmPointStrain.appendChild(doc.createTextNode(String.valueOf(fmt.format(strain.getElement(i)))));
									elmPointStrain.appendChild(doc.createTextNode(" "));
								}
								elmSectionPoint.appendChild(elmPointStrain);
	
								// Creating DOM elements "Stresses"
								org.w3c.dom.Element elmPointStress = doc.createElement("Stresses");
								fmt.applyPattern("0.000E00");
								IVector stress = dg.getMPDualInternalVariables(elemDegenerationPoint.getLabel(), strain);
								for (int i = 0; i < elemDegenerationPoint.getContinuousPointModel().getNumberOfDualInternalVariables(); i++) {
									elmPointStress.appendChild(doc.createTextNode(String.valueOf(fmt.format(stress.getElement(i)))));
									elmPointStress.appendChild(doc.createTextNode(" "));
								}
								elmSectionPoint.appendChild(elmPointStress);
							}
	
						} else {
	
						}
	
					}//End of creating DOM elements "Degeneration"
				}
				// End of creating DOM elements "DegenerationList"

			}
			// End of creating DOM elements "Element"

			// ***LOADINGLIST TREE***

			//Creating DOM element "LoadingList"
			org.w3c.dom.Element elmLoadingList = doc.createElement("LoadingList");
			root.appendChild(elmLoadingList);

			ListIterator loadings = model.getLoadingList().listIterator();
			while (loadings.hasNext()) {

				loading = (Loading) loadings.next();

				// Creating DOM element "Loading"
				org.w3c.dom.Element elmLoading = doc.createElement("Loading");
				elmLoading.setAttribute("label", "" + loading.getLabel());
				elmLoadingList.appendChild(elmLoading);
								
				//Creating DOM element "NodeLoad"
				nodes = model.getNodesList().listIterator();
				int ndf = ((PointValues) model.getGlobalAnalysisModel().getDOFLabels(1).get(0)).getSize();
				while (nodes.hasNext()) {

					node = (Node) nodes.next();
					fmt.applyPattern("###0.000");

					if (loading.nodalValuesContainsKey(node)) {
						org.w3c.dom.Element elmNodeLoad = doc.createElement("NodeLoad");
						elmNodeLoad.setAttribute("node", "" + node.getLabel());
						for (int i = 0; i < ndf; i++) {
							elmNodeLoad.appendChild(doc.createTextNode(String.valueOf(fmt.format(loading.getNodalValues(node).getDoublePointValue(i)))));
							if (i != ndf - 1) {
								elmNodeLoad.appendChild(doc.createTextNode(" "));
							}
						}
						elmLoading.appendChild(elmNodeLoad);
					}
				}

			}
			// End of creating DOM elements "LoadingList"

			// ***LOADCOMBINATIONS TREE***

			// Creating DOM element "LoadCombinations"
			org.w3c.dom.Element elmLoadCombinations = doc.createElement("LoadCombinations");
			root.appendChild(elmLoadCombinations);

			ListIterator lcombs = model.getLoadCombinationsList().listIterator();
			while (lcombs.hasNext()) {

				lcomb = (LoadCombination) lcombs.next();

				// Creating DOM element "LoadCombination"
				org.w3c.dom.Element elmLoadCombination = doc.createElement("LoadCombination");
				elmLoadCombination.setAttribute("label", "" + lcomb.getLabel());
				elmLoadCombinations.appendChild(elmLoadCombination);

				ListIterator loadCases = lcomb.getLoadCasesList().listIterator();
				while (loadCases.hasNext()) {

					loadcase = (LoadCase) loadCases.next();

					fmt.applyPattern("0.000E00");
					// Creating DOM element "LoadCase"
					org.w3c.dom.Element elmLoadCase = doc.createElement("LoadCase");
					elmLoadCase.setAttribute("factor", "" + (String.valueOf(fmt.format(loadcase.getFactor()))));
					elmLoadCase.setAttribute("inc", "" + loadcase.isIncremental());
					elmLoadCase.setAttribute("loading", "" + loadcase.getLabel());
					elmLoadCombination.appendChild(elmLoadCase);
				}

			}
			// End of creating DOM elements "LoadCombination"

			docOutput = doc;

		}
		// end of try
		catch (ParserConfigurationException pce) {
			System.out.println("Could not create DOM parser.");
			System.out.println(pce.getMessage());
			System.exit(4);
		}

	}
	// END OF FILLFILEFROMMODEL

	/**
	 *  Serializes the DOM tree into a XML file.
	 *
	 *@param  resultFile  The name of the output file.
	 */
	public void serializeDOMTreeIntoXMLDocument(String resultFile) {
		try {
			TransformerFactory tf = TransformerFactory.newInstance();
			tf.setAttribute("indent-number", new Integer(4));
			Transformer t = tf.newTransformer();
			t.setOutputProperty(OutputKeys.INDENT, "yes");
			t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
			t.transform(new DOMSource((Document) docOutput),new StreamResult(new FileWriter(resultFile)));
		} catch (TransformerException te) {
			System.out.println("Problem serializing DOM tree");
			System.out.println(te.getMessageAndLocation());
			System.exit(1);
		} catch (IOException e) {
			System.out.println("Problem serializing DOM tree");
			System.out.println(e.getLocalizedMessage());
			System.exit(1);
		}
	}

	/*
	 *  (non-Javadoc)
	 *  @see java.util.Observer#update(java.util.Observable, java.lang.Object)
	 */
	public void update(Observable o, Object arg) {
		Solver.endTime = System.currentTimeMillis();
		if(path.equals("")){
			File newdir0 = new File("RESULTS");
			if (newdir0.mkdir()) {
				;
			}
			File newdir1 = new File(newdir0.getAbsolutePath() + File.separator + solution.getLabel());
			if (newdir1.mkdir()) {
				;
			}
			File newdir = new File(newdir1.getAbsolutePath() + File.separator + "XMLs");
			if (newdir.mkdir()) {
				;
			}
			this.fillFileFromModel();
			if (solution.getClass().getName().equals("br.ufmg.dees.insane.solution.EquilibriumPath")) {
				DecimalFormat fmt = new DecimalFormat();
				fmt.applyPattern("000");
				this.serializeDOMTreeIntoXMLDocument(newdir.getAbsolutePath() + File.separator + solution.getLabel() + "-STEP-" + fmt.format(((EquilibriumPath) solution).getStep().getLabel()) + ".xml");
			}
			if (solution.getClass().getName().equals("br.ufmg.dees.insane.solution.SteadyState")) {
				File newdir2 = new File(newdir1.getAbsolutePath() + File.separator + "XMLs");
				if (newdir2.mkdir()) {
					;
				}
				this.fillFileFromModel();
				this.serializeDOMTreeIntoXMLDocument(newdir.getAbsolutePath() + File.separator + solution.getLabel() + "-LoadComb" + ((LoadCombination) model.getLoadCombinationsList().get(q)).getLabel() + ".xml");
				q++;
			}
		}else{
			File newdirPath = new File(path);
			if (newdirPath.mkdir()) {
				;
			}
			
			File newdir0 = new File(newdirPath.getAbsolutePath()+ File.separator+"RESULTS");
			if (newdir0.mkdir()) {
				;
			}
			File newdir1 = new File(newdir0.getAbsolutePath() + File.separator + fileName);
			if (newdir1.mkdir()) {
				;
			}
			File newdir = new File(newdir1.getAbsolutePath() + File.separator + "XMLs");
			if (newdir.mkdir()) {
				;
			}
			this.fillFileFromModel();
			if (solution.getClass().getName().equals("br.ufmg.dees.insane.solution.EquilibriumPath")) {
				DecimalFormat fmt = new DecimalFormat();
				fmt.applyPattern("000");
				this.serializeDOMTreeIntoXMLDocument(newdir.getAbsolutePath() + File.separator + fileName + "-STEP-" + fmt.format(((EquilibriumPath) solution).getStep().getLabel()) + ".xml");
			}
			if (solution.getClass().getName().equals("br.ufmg.dees.insane.solution.SteadyState")) {
				File newdir2 = new File(newdir1.getAbsolutePath() + File.separator + "XMLs");
				if (newdir2.mkdir()) {
					;
				}
				this.fillFileFromModel();
				this.serializeDOMTreeIntoXMLDocument(newdir.getAbsolutePath() + File.separator + fileName + "-LoadComb" + ((LoadCombination) model.getLoadCombinationsList().get(q)).getLabel() + ".xml");
				q++;
			}
		}
		
	}	
}